tags:

views:

71

answers:

3

Is it possible to specify multiple file names on the command line when starting vi?

+5  A: 

Yep just use :n to go to the next file in the list, and :N to go to the previous.

Alex Howansky
thanks...one other things in vi "y5w" yanks five words from cursor position?
also, :buffers shows a nice list of opened files.
ninjalj
+1  A: 

You can open multiple files by using globbing E.g., vi *.html will open all the HTML files in your current directory. And, as Alex says in his answer, you can navigate back and forth through the files with :n and :N.

If you want to open multiple files at the same time, you can also use the split command.

Open the first file as usual, then, then use the command :split yourfile.ext

You should now see both files at the same time in a split-screen view. You can do this with more than 2 files (but I'm not sure what the limit is).

Now, you can navigate between the windows with ctrl-w and the arrow keys. So, if you're in the bottom pane, and you want your cursor in the upper pane, you'd first press ctrl-w, then press the up-arrow key.

Also, you can resize one of the panes by adding or subtracting rows/lines in that view. So if you're in the upper pane and you want it to be 5 lines larger, you'd press 5, then ctrl-w, then +. Same for reducing with the - key.

I'm sure that there are many other commands you can use, but these are the ones I use.

Good luck!

mkoistinen
+1  A: 

Also convenient:

vim -p file1 file2 file3

That will open up vim with tabs containing each file specified. You can jump between files with

gt 

and

gT

If you do

:set mouse=a 

you can also click on the tabs to open or drag them (although hardcore vim users would frown on this :) )

thedayturns