Switching between multiple files
(Check an even easier wasy using Vim >7 below!)
Open multiple files at once with e.g. vi main.pl maintenance.pl and then hop between them with:
:n
:prev
and see which file are open with :args
You can also create a split screen view using :sp <filename>
or :sp and then execute :n to open the next file
You can also use tabs (introduced in Vim 7)
Opening multiple files in several tabs:
vim -p file1 file2 file3
You can switch between tabs with :tabn and :tabp (or use the GUI!!), With :tabe <filepath> or :tabnew <filepath> you can add a new tab; and with a regular :q or :wq you close a tab. If you map :tabn and :tabp to your F7/F8 keys you can easily switch between files.
Of course, you can open an empty tab just by typing :tabnew or :tabe (there is no need to use a filename to open a new file )
Using buffers
http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/vi-ex/node23.html
> If you have a lot of files open in Vim, how do you switch to the one >
you want in the easiest fashion?
:help buffer
:b N
or
:b filename
Next buffer:
:bn
Previous
:bp
To open a split screen use any of the previous commands but add an "s" in front of it. ie:
:sb 2
If there are not that many files and you don't have Vim 7 you can also split your screen in multiple files: :sp <filepath>
. Then you can switch between splitscreens with Ctrl+W and then a arrow key in the direction you want to move.
Mixing tabs and buffers
To retab all files in buffer list
:tab sball
Comments