Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

vim - 如何有效地在Vim中处理多个文件?(How to effectively work with multiple files in Vim?)

I've started using Vim to develop Perl scripts and am starting to find it very powerful.

(我已经开始使用Vim开发Perl脚本,并且开始发现它非常强大。)

One thing I like is to be able to open multiple files at once with eg vi main.pl maintenance.pl and then hop between them with:

(我喜欢的一件事是能够使用vi main.pl maintenance.pl例如一次打开多个文件,然后使用以下命令在它们之间跳转:)

:n
:prev

and see which file are open with

(并查看打开哪个文件)

:args

And to add a file, I can say:

(要添加文件,我可以说:)

:n test.pl

which I expect would then be ADDED to my list of files, but instead it wipes out my current file list and when I type :args I only have test.pl open.

(我希望它将添加到我的文件列表中,但是它将清除当前文件列表,当我键入:args我只打开了test.pl)

So how can I ADD and REMOVE files to my args list?

(那么如何将文件添加和删除到我的args列表中?)

  ask by Edward Tanguay translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Why not use tabs (introduced in Vim 7)?

(为什么不使用选项卡(在Vim 7中引入)?)

You can switch between tabs with :tabn and :tabp , With :tabe <filepath> you can add a new tab;

(您可以使用:tabn:tabp在标签之间切换,使用:tabe <filepath>您可以添加新标签;)

and with a regular :q or :wq you close a tab.

(并使用常规的:q:wq关闭选项卡。)

If you map :tabn and :tabp to your F7 / F8 keys you can easily switch between files.

(如果将:tabn:tabpF7 / F8键,则可以轻松地在文件之间切换。)

If there are not that many files or you don't have Vim 7 you can also split your screen in multiple files: :sp <filepath> .

(如果没有那么多文件,或者您没有Vim 7,也可以将屏幕拆分为多个文件:sp <filepath> 。)

Then you can switch between splitscreens with Ctrl + W and then an arrow key in the direction you want to move (or instead of arrow keys, w for next and W for previous splitscreen)

(然后,您可以使用Ctrl + W ,然后按您要移动的方向使用箭头键在拆分屏幕之间进行切换(或者用箭头键代替w ,代表下一个, W代表上一个拆分屏幕,而不是箭头键))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...