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>
精彩评论