I am using CtrlW to navigate between VIM split windows. Does there exist any different ways to do this?
For example, if I have, say, 5 split windows opened and want to navigate to the top left corner window, CtrlW is very uncomfortable as it requires many keystrokes.
Control + W followed by W to toggle between open windows and, Control + W followed by H / J / K / L to move to the left/bottom/top/right window accordingly, Control + W followed by Left / Down / Up / Right arrow to move to the left/bottom/top/right window accordingly.
Example: :wincmd j Moves to the window below the current one. This command is useful when a Normal mode cannot be used (for the |CursorHold| autocommand event). Or when a Normal mode command is inconvenient. The count can also be a window number.
Ctrl-w = tells Vim to assign an equal number of lines to each viewport. To move between the viewports while working, use Ctrl-w j to move down, and Ctrl-w k to move up.
Why not setup something like these?
nnoremap <C-h> <C-w>h nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-l> <C-w>l
Much quicker ...
You can use <number><c-w>w
to switch to a particular window. So 1<c-w>w
goes the the first window (top left corner) 11<c-w>w
moves to the last window (here I assume you have less than 11 splits).
I also find the following mappings convenient and have them in my .vimrc
nnoremap <tab> <c-w> nnoremap <tab><tab> <c-w><c-w>
which I use for window stitching (for some reason if I don't define the second mapping if I hit tab twice I get a message "no identifier under the cursor)
Reading the help page for CTRL-W, there is even a more convenient way than 1<c-w>w
and 11<c-w>w
to go to the first and last window: <c-w>t
goes to the top window and <c-w>b
goes to the bottom window.
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