I\'ve started using Vim to develop Perl scripts and am starting to find it very powerful.
One thing I like is to be able to open multiple files at once with:
<When using multiple files in vim, I use these commands mostly (with ~350 files open):
:b <partial filename><tab>
(jump to a buffer):bw
(buffer wipe, remove a buffer):e <file path>
(edit, open a new buffer>pltags
- enable jumping to subroutine/method definitions:ls
for list of open buffers
:bp
previous buffer:bn
next buffer:bn
(n
a number) move to n'th buffer:b <filename-part>
with tab-key providing auto-completion (awesome !!)In some versions of vim, bn
and bp
are actually bnext
and bprevious
respectively. Tab auto-complete is helpful in this case.
Or when you are in normal mode, use ^
to switch to the last file you were working on.
Plus, you can save sessions of vim
:mksession! ~/today.ses
The above command saves the current open file buffers and settings to ~/today.ses
. You can load that session by using
vim -S ~/today.ses
No hassle remembering where you left off yesterday. ;)
Things like :e
and :badd
will only accept ONE argument, therefore the following will fail
:e foo.txt bar.txt
:e /foo/bar/*.txt
:badd /foo/bar/*
If you want to add multiple files from within vim, use arga[dd]
:arga foo.txt bar.txt
:arga /foo/bar/*.txt
:argadd /foo/bar/*
If you are going to use multiple buffers, I think the most important thing is to set hidden so that it will let you switch buffers even if you have unsaved changes in the one you are leaving.
I would suggest using the plugin
NERDtree
Here is the github link with instructions.
Nerdtree
I use vim-plug as a plugin manager, but you can use Vundle as well.
vim-plug
Vundle
You can be an absolute madman and alias vim
to vim -p
by adding in your .bashrc
:
alias vim="vim -p"
This will result in opening multiple files from the shell in tabs, without having to invoke :tab ball
from within vim afterwards.