开发者

What mapping should I add to my .vimrc that will allow me to split a buffer/window vertically/horizontally in VIM?

开发者 https://www.devze.com 2023-02-03 08:10 出处:网络
I just want to be able to split my VIM buffers/windows vertically and/or horizontally with a keyboard shortcut. I would like to use the following shortcuts:

I just want to be able to split my VIM buffers/windows vertically and/or horizontally with a keyboard shortcut. I would like to use the following shortcuts:

Vertical split

,v

Horizontal split

,h开发者_运维知识库

That would be a , (comma) followed by a v to vertically split a buffer & , (comma) followed by a h to horizontally split a buffer.


You could try to learn directly the commands

<C-w>s
<C-w>v

for the horizontal and vertical splits. I use the mapping

nnoremap ,w <C-w>

for <C-w> so for the splits I type ,ws or ,wv

The advantage of this is that it allows you to use ,w for all the other mappings provided by <C-w>

One last mapping I find useful in this context is

nnoremap ,, <C-w><C-w>

for changing between the various splits.


nnoremap ,v <C-w>v
nnoremap ,h <C-w>s


nnoremap ,v :vsplit<CR>
nnoremap ,h :split<CR>
0

精彩评论

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