To open a new VIM window next to the existing one, press <Ctrl>+<w> then press <v>. You can move to the left window again by pressing <Crtl>+<w> and then pressing <h>. To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>.
To directly move to first tab or last tab, you can enter the following in command mode: :tabfirst or :tablast for first or last tab respectively. To move back and forth : :tabn for next tab and :tabp for previous tab. You can list all the open tabs using : :tabs. To open multiple files in tabs: $ vim -p source.
With vim, you can use tabs also, just like you would in gvim or any other GUI editor. This will open three tabs, each containing the specified file. The second way to open files is to create new tabs within vim and open files using :tabnew file.
#
is simply an Ex special character that will be replaced with the name of the alternate file. Do an :ls
, and the alternate file will be marked with a #
there also.
#
can similarly be used with :tabnew
and split
. In the examples below I'll use :tabe
in place of :tabnew
as :tabe
is a shorter alias for :tabnew
(search for either in the help docs):
:tabe#
:split#
; this can be abbreviated to :sp#
, and :vsp#
for a vertical split.Using a buffer number from :ls
, e.g. buffer number 5 you can also:
:sp#5
; alternately :sb5
if the switchbuf
option contains the newtab
specifier - see :help switchbuf
:vsp #5
(there is no :vsb
):tabe #5
You don't necessarily have to leave normal mode to open the alternate buffer in a new window:
CTRL-W ^ opens the alternate buffer in a horizontal split.
CTRL-W T opens the current buffer in a new tab (Shift-T, that is).
So, one solution to your title question is the following combo.
CTRL-W ^, CTRL-W T: opens the alternate buffer in a new tab.
Note that for the caret "^" in the first command you don't have to release the Control key and you don't have to press Shift, just hold down CTRL then strike W and 6 (where the caret is located on many English keyboard layouts).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With