0

I can resize horizontal split windows by ctrl-w-shift-< and ctrl-w-shift->. I would like to have a shortcut for that.

Close to the topic, recently I learned about the following maps:

nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l

So I tried:

nnoremap <C-\<> <C-w>\<
nnoremap <C-\>> <C-w>\>

But it seems not to be working.

While waiting for an answer I'm using @john-mo mouse approach from How do I change the current split's width and height?

2

Your mappings have two problems:

One problem can be solved easily: you don't need to escape < and > in the right-hand part of the mappings, for example, these ones work properly:

nnoremap <C-a> <C-w>>
nnoremap <C-b> <C-w><

Your second problem, which can't really be solved is that you're trying to map Ctrl + <, which is not possible. So you should try to use another key combination. (I already wrote an answer about how to debug a mapping which could have been useful to you in this case: How to debug a mapping?)

1

While you can't use Ctrl+< and Ctrl+>, many terminals will support alt+, (comma) and alt+. (period), although it's not obvious at first how to do this:

execute "set <a-,>=\<esc>,"
execute "set <a-.>=\<esc>."
nnoremap <silent> <a-,> :<c-u>vert res -<c-r>=v:count?v:count1:5<cr><cr>
nnoremap <silent> <a-.> :<c-u>vert res +<c-r>=v:count?v:count1:5<cr><cr>

You can supply a count or use the default of 5.

With alt maps I recommend using

set ttimeout ttimeoutlen=10

otherwise there can be a delay when pressing esc as vim waits to see if a , or . is coming.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.