Vim: 需要一个函数来按名称切换到活动缓冲区

Vim: need a function to switch to an active buffer by name

假设我在某些 window 上打开了一个终端缓冲区,其中包含所需的缓冲区大小等。 我想切换到使用热键打开的 window。 我可以用一些大的 '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