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 <Cw>
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 <Cw>
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 :split<enter>
nnoremap ,h :vsplit<enter>
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.