说,我在某个窗口上打开了带有所需缓冲区尺寸等的终端缓冲区。 我想切换到使用热键打开的窗口。 我可以用一些大的“ 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插件具有该功能,但我无法将其淘汰。当您为我做的时候将不胜感激=)
答案 0 :(得分:2)
" 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