Reputation: 4020
If I want to open a split in vim, I do :sp %
- that will, in this case, do a horizontal split with the file in my current buffer and window. :vsp
is the same thing but vertically.
Now lets say I already have a vertical split and I am in the window to the right. What would I do if I wanted to horizontally split the file in the window to the right without specifying its path. I believe I have seen this with +
or ,
, but I cannot seem to find it, and don't know much about this murky part of vim.
Visual representation or what I want
+~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~+
| ./test1 | ./test2 |
| Stuff in my other | I am currently in |
| window | this file ... |
| bla foo | |
| bla | |
| bla bar | |
| | |
| | :sp ./te[tab] |
+~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~+
The above works, but I would like to to specify the window to the left without the filename.
Any thoughts?
Upvotes: 1
Views: 82
Reputation: 45177
You can do the following to split the current file with out specifying the file name or %
.
:sp
:vsp
If commands aren't your thing you can use window mappings:
<c-w>s
<c-w>v
Split with :split
and :vsplit
with a filename.
:split foo.txt
:vsplit bar.txt
Just like :edit
you can do the following:
<tab>
completion<c-d>
:sp *foo
or :sp **/*foo
%
tricks. e.g. :e %<.h
, :e %:h/bar.txt
. See :_%
#
. e.g :e #
. Note: <c-^>
is probably a better optionUse :sbuffer
as a split variant of :buffer
.
:sb foo
:sb 7
Use :vert sb
for vertical splits.
Behold the power of :b
:
<tab>
completion<c-d>
to list out completion:b foo
. Works great with <tab>
.:b foo*bar
or :b foo/**/bar
'hidden'
via set hidden
:b
is :sb
.A common mapping:
nnoremap <leader>b :ls<cr>:b<space>
Moving a split can be accomplished via window mappings
<c-w>J
move split down<c-w>K
move split up<c-w>H
move split left<c-w>L
move split right:h window
:h :sp
:h :sb
:h :b
:h 'hidden'
:h :_%
:h CTRL-W
Upvotes: 3