Skip to content

Instantly share code, notes, and snippets.

View saihoooooooo's full-sized avatar
♨️
noop

shinya.saiho saihoooooooo

♨️
noop
View GitHub Profile
@saihoooooooo
saihoooooooo / gist:1414462
Created December 1, 2011 06:55
my unite_source_file_mru_ignore_pattern
let g:unite_source_file_mru_ignore_pattern = ''
let g:unite_source_file_mru_ignore_pattern .= '\~$'
let g:unite_source_file_mru_ignore_pattern .= '\|\.\%(o\|exe\|dll\|bak\|sw[po]\)$'
let g:unite_source_file_mru_ignore_pattern .= '\|\%(^\|/\)\.\%(hg\|git\|bzr\|svn\)\%($\|/\)'
let g:unite_source_file_mru_ignore_pattern .= '\|^\%(\\\\\|/mnt/\|/media/\|/Volumes/\)'
let g:unite_source_file_mru_ignore_pattern .= '\|AppData/Local/Temp'
@saihoooooooo
saihoooooooo / gist:1445997
Created December 8, 2011 03:37
toggle option function
nnoremap [Option] <Nop>
nmap xo [Option]
nnoremap <silent>[Option]n :<C-u>call <SID>ToggleOption('number')<CR>
nnoremap <silent>[Option]w :<C-u>call <SID>ToggleOption('wrap')<CR>
nnoremap <silent>[Option]/ :<C-u>call <SID>ToggleOption('wrapscan')<CR>
function! s:ToggleOption(option)
if has_key(g:toggle_option_extra, a:option)
for e in g:toggle_option_extra[a:option]
if exists('+' . e) && eval("&" . e) == 0
execute 'setlocal' e . '!' e . '?'
@saihoooooooo
saihoooooooo / gist:1446321
Created December 8, 2011 06:48
drop undo info
nnoremap xU :<C-u>call <SID>DropUndoInfo()<CR>
function! s:DropUndoInfo()
if &modified
echoerr "This buffer has been modified!"
return
endif
let l:old_undolevels = &undolevels
set undolevels=-1
execute "normal! aa\<BS>\<ESC>"
let &modified = 0
@saihoooooooo
saihoooooooo / gist:1450303
Created December 9, 2011 05:22
Abbreviation of the datetime
iabbrev *datetime* <C-r>=strftime("%Y/%m/%d %H:%M:%S")<CR><C-R>=<SID>Eatchar('\s')<CR>
iabbrev *date* <C-r>=strftime("%Y/%m/%d")<CR><C-R>=<SID>Eatchar('\s')<CR>
iabbrev *time* <C-r>=strftime("%H:%M:%S")<CR><C-R>=<SID>Eatchar('\s')<CR>
function! s:Eatchar(pattern)
let l:c = nr2char(getchar(0))
return (l:c =~ a:pattern) ? '' : l:c
endfunction
@saihoooooooo
saihoooooooo / gist:1450676
Created December 9, 2011 07:57
make ordered list
nnoremap <silent>xl :<C-u>call <SID>MakeOrderedList()<CR>
function! s:MakeOrderedList()
let l:count = v:count
normal! i1.
if l:count > 1
let @l = 'yyp'
execute 'normal!' (l:count - 1) . '@l'
endif
endfunction
@saihoooooooo
saihoooooooo / gist:1496652
Created December 19, 2011 11:01
my guitabline
autocmd MyAutoCmd GUIEnter * set guitablabel=%t%{GetTabModified()}\ [b:%{GetBufferTabLength()}]
function! GetTabModified()
for bufnr in tabpagebuflist(v:lnum)
if getbufvar(bufnr, "&modified")
return ' [+]'
endif
endfor
return ''
endfunction
function! GetBufferTabLength()
@saihoooooooo
saihoooooooo / gist:1749524
Created February 6, 2012 04:08
search operator by vim-operator-user
map x/ <Plug>(operator-search)
call operator#user#define('search', 'OperatorSearch')
function! OperatorSearch(motion_wise)
if a:motion_wise == 'char'
execute 'silent normal! `[v`]"zy'
call search(@z)
let @/ = @z
set hlsearch
endif
endfunction
@saihoooooooo
saihoooooooo / gist:1765850
Created February 8, 2012 05:42
auto lcd, and toggle command
if !exists('g:auto_lcd')
let g:auto_lcd = 1
endif
autocmd MyAutoCmd BufEnter * if g:auto_lcd | execute "lcd " . expand("%:p:h") | endif
command! -nargs=0 ToggleAutoLcd call <SID>ToggleAutoLcd()
function! s:ToggleAutoLcd()
lcd %:p:h
let g:auto_lcd = !g:auto_lcd
if g:auto_lcd
echo 'set autolcd'
@saihoooooooo
saihoooooooo / gist:1767578
Created February 8, 2012 09:59
Select the table with a column that contains 'user_id'
SELECT DISTINCT
class.relname
FROM
pg_attribute AS att
INNER JOIN pg_class AS class
ON class.oid = att.attrelid
WHERE
att.attnum > 0
AND att.attname = 'user_id'
AND class.relkind = 'r'
@saihoooooooo
saihoooooooo / gist:1777363
Created February 9, 2012 04:40
auto mark
nnoremap <silent>[Mark]m :<C-u>call <SID>AutoMark()<CR>
if !exists('g:marks_pos')
let g:marks_char = [
\ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
\ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
\ ]
endif
function! s:AutoMark()
if !exists('b:marks_current_pos') || (b:marks_current_pos == len(g:marks_char) - 1)
let b:marks_current_pos = 0