假设我在某个窗口上打开了一个终端缓冲区,其中包含所需的缓冲区尺寸等。我想切换到用热键打开它的窗口。我可以使用一些大的'Denite'插件来制作它:
function! FocusBufOrDo(arg,cmd)
if buflisted(bufname(a:arg))
" exec 'buffer ' . a:arg
exec 'Denite buffer -default-action=switch -mode=normal -immediately-1 -input=' . a:arg
elseif !empty(a:cmd)
" echo 'No such buffer'
exec a:cmd
endif
endfunc
nnoremap <Leader>c :call FocusBufOrDo('/usr/bin/bash','term')<CR>
nnoremap <Leader>gi : call FocusBufOrDo('gist:','tabe \| Gist bf39XXXXXXXXXXXXXXXXX5')<CR>
现在我想要一个专用的功能来进行切换。 Tselectbuffer或tlib插件具有该功能,但我无法将其删除。当你为我做这件事时会非常感激=)
" Run through the list of buffers,
" match buffer's filename with the argument,
" switch to the 1st window, if found.
function! GotoWindowByFileName(name)
for b in getbufinfo()
if b.name =~ a:name
call win_gotoid(b.windows[0])
return
endif
endfor
endfunction