开发者

What mappings would I have to add to .vimrc in order to create a shortcut that allows me to resize VIM buffers?

I would like to create a keyboard shortcut (mapping) in my .vimrc that will allow me to resize my horizontal/vertical buffers in VIM. Ideally the short cuts will be two key combos that are pressed like ...

  • CTRL + increase current buffer's size by moving right edge

  • CTRL + increase current buffer's size by moving left edge

  • CTRL + increase current buffer's size by moving top edge

  • CTRL + increase current buffer's size by moving bottom edge

... or something similar (but still two keys). Additionally these key mappings would behave in such开发者_JAVA百科 a way that when they are held down the buffer will continue to resize (like rapid fire). This will be faster that having to constantly execute the keyboard shortcut.


The following mapping somewhat works :

noremap <C-Up> <C-W>+
noremap <C-Down> <C-W>-
noremap <C-Left> <C-W>>
noremap <C-Right> <C-W><

After testing a bit, it is sometime a bit counter intuitive, if you try to increase the size of a vertically split buffer whith cursor in the top buffer, instinctively you want to use the down arrow to move the separation line down, and you actually have to use the up arrow to increase the buffer size.

Someone will probably come up with a better mapping but I don't know if it is possible to get a Window position (top or bottom for example) with a vim script function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜