开发者

Can you use vi with multiple file names specified on command line?

开发者 https://www.devze.com 2023-01-17 08:34 出处:网络
Is it possible to specify multiple file names o开发者_运维百科n the command line when starting vi?Yep just use :n to go to the next file in the list, and :N to go to the previous.You can open multiple

Is it possible to specify multiple file names o开发者_运维百科n the command line when starting vi?


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


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!


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 :) )

0

精彩评论

暂无评论...
验证码 换一张
取 消