简体   繁体   English

为了创建允许我调整VIM缓冲区大小的快捷方式,我必须在.vimrc中添加哪些映射?

[英]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 . 我想在.vimrc中创建一个键盘快捷方式(映射),该快捷方式将允许我调整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 + 通过移动右边缘来增加当前缓冲区的大小

  • CTRL + increase current buffer's size by moving left edge CTRL + 通过移动左边缘来增加当前缓冲区的大小

  • CTRL + increase current buffer's size by moving top edge CTRL + 通过移动顶部边缘来增加当前缓冲区的大小

  • CTRL + increase current buffer's size by moving bottom edge CTRL + 通过移动底部边缘来增加当前缓冲区的大小

... 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. 有人可能会想出更好的映射关系,但我不知道是否可以通过vim脚本功能获得Window位置(例如,顶部或底部)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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