There are some excellent Vim plugins for switching to a specific file or buffer by typing part of the name. Does anyone know of a plugin like these that allows for quickly switching between open windows?
For example, if I had a vsplit with a file named 'a.txt' on one side and 'b.txt' on another I'd like to be able to switch between them by typing the filename (or just 'a' or 'b' with incremental searching). This might not be too useful for two windows, but I often have up to 5 windows open, so switching between them using the normal navigation buttons can be a pain.
WinWalker seems to support this type of functionality, but wrapped inside of a much larger framework for window navigation.
To move from the current Vim window to the next one, type CTRL-W j (or CTRL-W <down> or CTRL-W CTRL-J). The CTRL-W is the mnemonic for “window” command, and the j is analogous to Vim's j command, which moves the cursor to the next line.
Just remember these commands to easily switch between buffers: :bf # Go to first file. :bl # Go to last file :bn # Go to next file. :bp # Go to previous file. :b number # Go to n'th file (E.g :b 2) :bw # Close current file.
wincmd is the vimscript equivalent to Ctrl w in normal mode.
:b
does that happily if you have :set
switchbuf
+=useopen
(in your vimrc). It supports file name completion, e.g. with Ctrl-D.
by MarcWeber et al from #vim
@Aaron Thoma' s answer with switchbuf+=useopen
did not work for me. Actually the doc does not mention that the setting is supported by :b
comand.
I've used the following snippet:
let windowNr = bufwinnr(pattern)
if windowNr > 0
execute windowNr 'wincmd w'
endif
See bufwinnr()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With