vimdiff and move among left and right pane
Solution 1
Ctrl+w
and right and left arrow can be used to move between any split windows on vim, not only vimdiff splits.
These keys do work here on cygwin; also, Ctrl+w w
also moves to the next window, but without the delay you mentioned.
It is possible that you have mapped these keys in your .vimrc or via some vim plugin. You can check this with :map w
, :map <left>
and :map <right>
.
As moving between windows is something that you use often, you may consider using the following mappings:
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
Then you can use Ctrl+h
and Ctrl+l
to move left and right, without moving your hands from the home row. And the nnoremap
will ensure that these works despite of any other mappings that you may have.
Solution 2
Press Ctrl + W and then (after releasing Ctrl + W) press the arrow keys to change the pane.
Solution 3
It is very useful to use set mouse=a
in your .vimrc
file. It gives you possibility to switch between windows using mouse. Additionally you can resize windows using it.
If you prefer to use keyboard I have also mapped arrow keys in .vimrc
in this way:
map <C-Left> <C-W>j
map <C-Down> <C-W>k
map <C-Up> <C-W>h
map <C-Right> <C-W>l
Related videos on Youtube
Cratylus
Updated on July 09, 2022Comments
-
Cratylus almost 2 years
I am using
vimdiff
for the first time. Online I found written that to move from the left pane you useCTRL + w + Left or right arrow
This does not work for me. But I see that if I press justCTRL + w
and pressw
for a sec and let it go, it switches pane after ~500ms.
Is this how it is supposed to work? Am I doing something wrong?-
glts almost 11 yearsPlease read
:h window-move-cursor
. -
FDinoff almost 11 yearsIts not supposed to be that slow. The lag on my set up is unnoticeable. Also you can use <Ctrl-W> h or l to move left or right.
-
Kent almost 11 yearsplease check if you have mapping with
ctrl-w w x y z
-
Cratylus almost 11 years@FDinoff:I tried <Ctrl-W> h but it does not work (at least in my cygwin)
-
-
sob almost 7 yearsGrzegorz, thanks for the tip.For me set mouse=a worked but set mouse=a' showed an error.
-
Grzegorz Bielański almost 7 yearsIt was typo. It should be mouse=a
-
Chan Kim over 3 yearswhat's the reverse of 'set mouse=a'? I forgot.
-
Chan Kim over 3 yearsoh it was
set mouse=
-
Chan Kim over 3 years@GrzegorzBielański Hi, how am I use the keyboard with the .vimrc setting above? can I move the center divider left or right using keyboard?
-
Stephen C over 3 yearsThis is for window rotation, not for moving between windows.
:h ctrl-w_ctrl-r
: "Rotate windows downward/rightwards. ... The cursor remains in the same window."