如何在 Vim 中有效地处理多个文件 [英] How to effectively work with multiple files in Vim
问题描述
我已经开始使用 Vim 来开发 Perl 脚本,并且开始发现它非常强大.
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:
vi main.pl maintenance.pl
然后在它们之间跳转:
:n
:prev
并查看打开的文件:
:args
要添加文件,我可以说:
And to add a file, I can say:
:n test.pl
然后我希望它会被添加到我的文件列表中,但它会清除我当前的文件列表,当我输入 :args
时,我只有 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 列表中添加和删除文件?
So how can I add and remove files in my args list?
推荐答案
为什么不使用制表符(在 Vim 7 中引入)?您可以使用 :tabn
和 :tabp
在选项卡之间切换,使用 :tabe
你可以添加一个新标签;并使用常规 :q
或 :wq
关闭选项卡.如果您将 :tabn
和 :tabp
映射到您的 F7/F8 键,您可以轻松地在文件之间切换.
Why not use tabs (introduced in Vim 7)?
You can switch between tabs with :tabn
and :tabp
,
With :tabe <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.
如果文件不多或者您没有 Vim 7,您也可以将屏幕拆分为多个文件::sp
.然后,您可以使用 Ctrl+W 在分屏之间切换,然后在要移动的方向上使用箭头键(或代替箭头键,w 用于下一个,W 用于上一个分屏)
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>
. 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)
这篇关于如何在 Vim 中有效地处理多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!