I am using NERDTree
on vim and usually open files with i
Is there an easy way to switch between different panes? Currently I use CTRL+W+W
to move from one pane to another.
Long ago I found a tip (once on vim.org, now on wikia, apparently) that I've stuck with. Remap ctrl-[hjkl]
to navigate splits. It has served me well.
" Use ctrl-[hjkl] to select the active split!
nmap <silent> <c-k> :wincmd k<CR>
nmap <silent> <c-j> :wincmd j<CR>
nmap <silent> <c-h> :wincmd h<CR>
nmap <silent> <c-l> :wincmd l<CR>
map <C-J> <C-w>j<C-w>_
and map <C-H> <C-w>h<C-w>\|
The _
and |
additions force the split to its full width or height when I switch.
May 19, 2011 at 4:38
h
direction my destination window was being messed up. Since the :wincmd
only makes difference off the normal mode and the mappings are used exactly in the normal mode, I have replaced nmap <silent> <c-h> :wincmd h<CR>
for nnoremap <silent> <c-h> <c-w>h
tmux
and it uses Ctrl + a
as prefix, I'll try disabling tmux
. Thanks :)
I know this is an old question, but I have a perfect way. Using the number of the split.
split_number C-w C-w
The panes are numbered from top-left
to bottom-right
with the first one getting the number 1
.
for example to go to split number 3 do this 3 C-w C-w
, press Ctrl-w
twice.
<C-split_number>
? E.g., I'd want <C-3>
to navigate to the 3rd split
I prefer hitting single keys over hitting key-chords. The following maps pane movement to arrow keys:
" Smart way to move between panes
map <up> <C-w><up>
map <down> <C-w><down>
map <left> <C-w><left>
map <right> <C-w><right>
Key mappings are definitely the way to go. I use the mappings mentioned by overthink. I also include the following mappings in my vimrc to move the splits themselves.
" Move the splits arround!
nmap <silent> <c-s-k> <C-W>k
nmap <silent> <c-s-j> <C-W>j
nmap <silent> <c-s-h> <C-W>h
nmap <silent> <c-s-l> <C-W>l
This makes it so that if the split opens in the wrong spot (lets say the left side and I want it on the right) I go to that split and hit <C-S-l>
and the split moves where I want it to.
In order to be consistent with changing tabs via gt & gT, I'm currently trying out the g mappings for changing splits. I tend to hit the shift key as I go for the Ctrl key so this helps me avoid that mistake until I get better at not doing so.
nnoremap gh <C-W><C-H>
nnoremap gj <C-W><C-J>
nnoremap gk <C-W><C-K>
nnoremap gl <C-W><C-L>
Very easy way of achieving it. Type this shortcut twice, and that should work
ctrl+w ctrl+w
Currently I use CTRL+W+W to move from one pane to another.
So...
I have mapped ctrl+w ctrl+w
to <tab>
(under normal mode as in normal mode tab does not have any use)and that's have made my life easier as now I can switch between panes easily by pressing <tab>
.
For switching to a particular pane, I can press <i> + <tab>
to switch between panes as split window panes also got their own number which can replace i.
Ex. i = 1,2...n.
CTRL+W, [hjkl]
to navigate the panes/frames? That way if you have 4-6 windows open, you don't have to hitCTRL+W,W
over and over. I like overthink's keybindings, but then again I enjoy consistency across systems, and when I get used to keybindings I have a hard time relearning them. If I started using CTRL-H to go left, I'd probably end up hitting CTRL-H on systems w/o the keybinding, which actually prints the backspace character by default. Hell I used to press CTRL-H to delete things because the backspace didn't work on my machine!CTRL+W, [hjkl]
to navigate the panes works perfectly! Thank you.