Skip to content

Instantly share code, notes, and snippets.

View thinca's full-sized avatar
⌨️
Happy Vimming!

thinca thinca

⌨️
Happy Vimming!
View GitHub Profile
let s:S = vital#vital#import('Data.String')
let s:L = vital#vital#import('Data.List')
function! s:count_words(text) abort
let F = { memo, x -> extend(memo, {x: get(memo, x, 0) + 1}) }
return s:L.foldl(F, {}, s:S.scan(a:text, '\w\+'))
endfunction
echo s:count_words('this is a pen or not a pen')
" {'this': 1, 'is': 1, 'a': 2, 'pen': 2, ...}
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@thinca
thinca / test.rb
Last active December 16, 2015 23:09 — forked from supermomonga/test.rb
Signal.trap(:QUIT) do
puts "QUIT signal sent."
exit 0
end
puts "Signal.list['QUIT'] => #{Signal.list['QUIT']}"
puts "My pid is #{$$}\n"
loop do
puts 'I\'m alive!'
" ~/.vim/syntax/markdown.vim
" \c で 大文字小文字無視します :help /\c
" todo: TODO: をハイライトしたい
syntax match myTodo /\ctodo:/ containedin=ALL
" done: DONE: をハイライトしたい
syntax match myDone /\cdone:/ containedin=ALL
" 適当に色付け
highlight link myTodo Todo
@thinca
thinca / fmv.vim
Created January 27, 2012 10:38 — forked from h-east/fmv.vim
Create vimdoc-ja folder structure and move files. (for iOS Vim ja-help)
call mkdir("vimdoc-ja/doc", "p")
call mkdir("vimdoc-ja/syntax", "p")
call rename("help_ja.vim","vimdoc-ja/syntax/help_ja.vim")
for s:file in split(glob('*.jax'), "\n")
call rename(s:file, "vimdoc-ja/doc/" . s:file)
endfor
vnew
setlocal bufhidden=hide buftype=nofile noswapfile nobuflisted
let s:doyagao = {'counter': 0, 'save_updatetime': &updatetime, 'bufnr': bufnr('%')}
function! s:doyagao.funcall() dict
if self.bufnr !=# bufnr('%')
call self.clear()
return
@thinca
thinca / .vimrc
Created May 16, 2010 00:20 — forked from tyru/.vimrc
" <Space><C-n>, <Space><C-p>: Move window position {{{
nnoremap <silent> <Space><C-n> :<C-u> call <SID>swap_window(v:count1)<CR>
nnoremap <silent> <Space><C-p> :<C-u> call <SID>swap_window(-v:count1)<CR>
function! s:modulo(n, m) "{{{
let d = a:n * a:m < 0 ? 1 : 0
return a:n + (-(a:n + (0 < a:m ? d : -d)) / a:m + d) * a:m
endfunction "}}}
function! s:swap_window(n) "{{{
@thinca
thinca / .vimrc
Created March 20, 2010 19:24 — forked from tyru/.vimrc
function! s:uniq(list) "{{{
let s:dict = {}
let counter = 1
for i in a:list
if !has_key(s:dict, i)
let s:dict[i] = counter
let counter += 1
endif
endfor
@thinca
thinca / gist:261452
Created December 22, 2009 02:41 — forked from Shougo/gist:261441
function! s:ParseMarkdown()
return map(split(join(getline(1, '$'), "\n"), '\v(^|\n)\ze#+'), 'split(v:val, "\n")')
endfunction
" Usage
let s:pages = s:ParseMarkdown()
let s:max_page_number = len(s:pages) - 1
"=============================================================================
" FILE: poslist.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" MODIFIED BY: thinca <thinca@gmail.com>
" Last Modified: 23 Jan 2010
" Usage: Just source this file.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including