…俺は…一体何を?
dirz.vim
if!exists('g:netrw_bookmarklist')
source $VIMFILES/.netrwbook
endiffunction! dirz#openFile(...) abort
let path = exists('a:1') ? a:1:''let drx = exists('a:2') ? a:2:''let isBang = exists('a:3') ? a:3:''let len = exists('a:4') ? a:4:''let explore = isBang =='!' ? 'aboveleft ':''if drx !~'[fF]$'if drx =~'^[vV]$'let explore = explore.'vsplit'elseif drx =~'^[sS]$'let explore = explore.'split'elselet explore = explore.'split'endiflet postLen = len =~'^0\?$' ? '': printf('%d', len)
execute printf(':%s%s %S', postLen, explore, path)else
execute printf(':edit! %S', path)endifendfunctionfunction! dirz#openDir(...) abort
let path = exists('a:1') ? a:1:''let drx = exists('a:2') ? a:2:''let isBang = exists('a:3') ? a:3:''let len = exists('a:4') ? a:4:''if drx !~'^[fF]$'if drx =~'^[vV]$'let postBang = isBang =='!' ? '':'!'elselet postBang = isBang
endiflet postLen = len =~'^0\?$' ? '': printf('%d', len)let explore = drx.'explore'.postBang
let explore = toupper(explore[0]).explore[1:-1]
execute printf(':%s%s %S', postLen, explore, path)else
execute printf(':edit! %S', path)endifendfunctionfunction! dirz#netrwBook(...) abort
let cIdx = exists('a:1') ? a:1:''let drx = exists('a:2') ? a:2:''let isBang = exists('a:3') ? a:3:''if cIdx >0let selectIdx = cIdx
elselet idx =1forning:netrw_bookmarklist
echo printf('%3d: %s',idx,n)let idx +=1endforcall inputsave()let selectIdx = input('番号と<Enter>を入力して下さい (空でキャンセル): ')call inputrestore()
echo "\r"endifcall dirz#openDir(g:netrw_bookmarklist[selectIdx-1], drx, isBang,)redrawendfunctionfunction dirz#localBook(...) abort
let key = exists('a:1') ? a:1:''let drx = exists('a:2') ? a:2:''let isBang = exists('a:3') ? a:3:''let len = exists('a:4') ? a:4:''if key ==''let dialog =''for bookKey in keys(g:dirzBook)let dialog = dialog.printf("%S -> %S\n", bookKey,g:dirzBook[bookKey])endforcall inputsave()let selectKey = input(dialog.'ブックマーク先に移動する場合キーを入力して下さい。 : ')call inputrestore()elselet selectKey = key
endifif selectKey !=''ifg:dirzBook[selectKey][-1]=~'^[\\\/]$'call dirz#openDir(g:dirzBook[selectKey], drx, isBang, len)elsecall dirz#openFile(g:dirzBook[selectKey], drx, isBang, len)endifendifredrawendfunction
command!-count -bang Bookz call dirz#netrwBook(<count>,'s','<bang>')
command!-count -bang VBookz call dirz#netrwBook(<count>,'v','<bang>')
command!-count -bang FBookz call dirz#netrwBook(<count>,'f','<bang>')
command!-count -bang Dirz call dirz#localBook(<count>,'s','<bang>')
command!-count -bang VDirz call dirz#localBook(<count>,'v','<bang>')
command!-count -bang FDirz call dirz#localBook(<count>,'f','<bang>')
noremap <Plug>(dirz_netrwBookS):<C-u>call dirz#netrwBook(v:count,'s','')<CR>
noremap <Plug>(dirz_netrwBookV):<C-u>call dirz#netrwBook(v:count,'v','')<CR>
noremap <Plug>(dirz_netrwBookF):<C-u>call dirz#netrwBook(v:count,'f','')<CR>
noremap <Plug>(dirz_localBookS):<C-u>call dirz#localBook(v:count,'s','')<CR>
noremap <Plug>(dirz_localBookV):<C-u>call dirz#localBook(v:count,'v','')<CR>
noremap <Plug>(dirz_localBookF):<C-u>call dirz#localBook(v:count,'f','')<CR>
これはな…ちゃうねん。
年末に部屋の片付けで名著「実践vim」を手放した名も知らぬ誰かのおかげで、若干のプレミアで済む範囲で紙の本が買えてしまったので読んでいるとものすごい勢いでモチベーションが上がったんです。で、「vimの操作を極めるためにvimrcの整理そのものを行う」という無間地獄に突入した結果、リマップを整理しようとしてトータルのスクリプト行数が増えるというわけのわからないことが起こりました。この後読書会なので解説を足す気力が起きないのでとりあえずソースだけ出してから明日説明することを考えます…vim内の辞書型変数からパスを読み出して開いたり、netrwのブックマークにnetrw外のバッファからジャンプしたりします。