Go to VIM window by name

There are some great Vim plugins for switching to a specific file or buffer by typing part of the name. Does anyone know of a plugin that allows you to quickly switch between open windows?

For example, if I have vsplit with a file named “a.txt” on one side and “b.txt” on the other, I would like to switch between them by typing the file name (or just “a 'or' b 'with incremental by searching.) This may not be very useful for two windows, but I often open up to 5 windows, so switching between them using regular navigation buttons can be a pain.

WinWalker seems to support this type of functionality, but is wrapped inside a much larger window navigation frame.

+3
source share
5 answers

:bdoes it happily if you have one (in your vimrc). It supports the file name completion , for example. with - .:set switchbuf +=useopenCtrlD

by MarcWeber et al of # vim

+3
source

I do not know how to switch to a window based on the file name, but I use the following shortcuts in mine .vimrcto move between windows.

noremap <S-W> <C-w><Up>
noremap <S-S> <C-w><Down>
noremap <S-A> <C-w><Left>
noremap <S-D> <C-w><Right>

It is just as simple, and I do not have more than four windows, so I have no more than 2 windows from any window. In addition, you do not need to enter a file name.

FPS, wasd, , , - , . , (hjkl )

Shift Ctrl/Alt/Option/Cmd, (, Fn macbook pro, Ctrl Mac) vim Linux, Cmd.

+1

Command-T. ( ) , . .vimrc :

nnoremap <S-F12> :CommandT<CR>

Shift-F12 , .

, .

0

This uses the python api, so you can only use it in vim, but I'm sure someone who loves the vim script can easily convert it.

Use it as follows:

:WSeek win
:WSeek READ
:WSeek README
:WSeek a.
etc.
I'm not afraid. Sorry ~
" Call using:
" :source window-swap.vim or put in plugins dir

function! WSeek(target) 
  if !has('python')
    echo "Error: this plugin requires vim with +python"
    finish
  else
python << EOF

import vim

target = vim.eval("a:target")
found = False
for i in range(0, len(vim.windows)):
  vim.command(str(i+1) + "wincmd w")
  bits = vim.current.buffer.name.split("/")
  bits = bits[-1]
  if (bits.startswith(target)):
    found = True
    break

# Go back to the start on no match
if not found:
  vim.command("1wincmd w")

EOF
  endif
endfunction 

command! -nargs=1 WSeek :call WSeek(<q-args>)
0
source

@ Aaron Toma s answer switchbuf+=useopendid not work for me. In fact, the document does not mention that the configuration is supported by the command :b.

I used the following snippet:

let windowNr = bufwinnr(pattern)
if windowNr > 0
  execute windowNr 'wincmd w'
endif  

See bufwinnr ()

0
source

All Articles