jhogendorn
jhogendorn

Reputation: 6140

Vim: Changing viewports quickly in normal mode

I use viewports extensively in vim, I'm forever splitting files into new viewports etc. I typically navigate around the viewports using Ctrl+W and a movement key, ie: hjkl.

Since there is a normal mode command for switching tabs quickly, gt, gT and ^gt, I was wondering if there is a normal mode equivalent without the modifier. If not, what would a good mapping be? gv and gw are both taken already.

Upvotes: 5

Views: 1036

Answers (2)

skeept
skeept

Reputation: 12423

I have the following mappings:

map <tab> <c-w>
map <tab><tab> <c-w><c-w>

so I can move quickly between windows with <tab>j, <tab>k, etc... Note that this also make easier to use all the other <c-w> mappings like <c-w>t to go to the first window or <c-w>b to go to the last window. These just become <tab>t and <tab>b.

Before using these mappings I was using

map ,w <c-w>

so again you would use this followed by a letter to move around the windows.

If you just want to stick to left, right, up and down then you can directly use something like

map ,l <c-w>l

and so on.

Upvotes: 1

user849425
user849425

Reputation:

For switching viewports quickly, I use the following:

noremap <C-J> <C-W>j<CR>
noremap <C-K> <C-W>k<CR>
noremap <C-H> <C-W>h<CR>
noremap <C-L> <C-W>l<CR>

Upvotes: 6

Related Questions