>>1280I see a lot of new Vim users misusing tabs, so I'll give tips about when and how they should be used.
In Vim, multifile editing is done through the use of buffers. A buffer is created every time a file is opened, or when an anonymous buffer is created using the
:new
command. Buffers can be switched between using
:bN
, where N is the number of the buffer (shown in
:ls
), or through
:bn
and
:bp
. To move between buffers in normal mode, use
N<C-^>
.
Tabs are not used to handle multiple files at once; rather, they're used to handle multiple
window configurations at once. Say one has four files open at once: main.c, main.h, helpers.c, helpers.h. In Vim, one can quickly establish an editing environment by doing something along the lines of:
$ vim *.[ch]
:vert sbn
:tabe
:b3
:vert sbn
gt
And of course, this being Vim, there are numerous ways to automate this process (see
:help autocommand
for one way).
One other tip: filenames in the current directory can be autocompleted in Insert Mode with
<C-x><C-f>
.