简体   繁体   中英

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 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> <CW>+
noremap <C-Down> <CW>-
noremap <C-Left> <CW>>
noremap <C-Right> <CW><

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM