我已经开始使用Vim来开发Perl脚本,并开始发现它非常强大。
我喜欢的一件事是能够同时打开多个文件:
vi main.pl maintenance.pl
然后在他们之间跳来跳去
:n
:prev
然后查看哪个文件是打开的:
:args
要添加一个文件,我可以说:
:n test.pl
我希望它会被添加到我的文件列表中,但相反,它会清除我当前的文件列表,当我输入:args时,我只有test.pl打开。
那么我如何在我的args列表中添加和删除文件?
我已经开始使用Vim来开发Perl脚本,并开始发现它非常强大。
我喜欢的一件事是能够同时打开多个文件:
vi main.pl maintenance.pl
然后在他们之间跳来跳去
:n
:prev
然后查看哪个文件是打开的:
:args
要添加一个文件,我可以说:
:n test.pl
我希望它会被添加到我的文件列表中,但相反,它会清除我当前的文件列表,当我输入:args时,我只有test.pl打开。
那么我如何在我的args列表中添加和删除文件?
当前回答
您可能希望使用Vim全局标记。
通过这种方式,您可以快速地在文件之间来回切换,甚至跳转到文件中标记的位置。此外,关键命令也很短: C会带我找到我正在处理的代码, T把我带到了我正在使用的单元测试。
当你改变位置时,重置标记也很快: mC标记新的代码点, mT标志着新的测试点。
其他回答
我使用缓冲区命令-:bn(下一个缓冲区),:bp(上一个缓冲区):buffers(列表打开缓冲区):b<n>(打开缓冲区n):bd(删除缓冲区)。:e <filename>将打开一个新的缓冲区。
我有效处理多个文件的方法是使用tmux。
它允许你垂直和水平分割窗口,如下所示:
I have it working this way on both my mac and linux machines and I find it better than the native window pane switching mechanism that's provided (on Macs). I find the switching easier and only with tmux have I been able to get the 'new page at the same current directory' working on my mac (despite the fact that there seems to be options to open new panes in the same directory) which is a surprisingly critical piece. An instant new pane at the current location is amazingly useful. A method that does new panes with the same key combos for both OS's is critical for me and a bonus for all for future personal compatibility. Aside from multiple tmux panes, I've also tried using multiple tabs, e.g. and multiple new windows, e.g. and ultimately I've found that multiple tmux panes to be the most useful for me. I am very 'visual' and like to keep my various contexts right in front of me, connected together as panes.
Tmux还支持水平和垂直窗格,这是旧屏幕所不支持的(尽管mac的iterm2似乎支持它,但是,当前的目录设置对我来说不管用)。tmux 1.8
当在vim中使用多个文件时,我主要使用这些命令(打开了大约350个文件):
:b <partial filename><tab>(跳转到缓冲区) :bw(缓冲区擦除,删除缓冲区) :e <文件路径>(编辑,打开一个新的缓冲区> . Pltags -允许跳转到子例程/方法定义
像:e和:badd这样的东西只接受一个参数,因此下面的将会失败
:e foo.txt bar.txt
:e /foo/bar/*.txt
:badd /foo/bar/*
如果您想从vim中添加多个文件,请使用arga[dd]
:arga foo.txt bar.txt
:arga /foo/bar/*.txt
:argadd /foo/bar/*
您可能希望使用Vim全局标记。
通过这种方式,您可以快速地在文件之间来回切换,甚至跳转到文件中标记的位置。此外,关键命令也很短: C会带我找到我正在处理的代码, T把我带到了我正在使用的单元测试。
当你改变位置时,重置标记也很快: mC标记新的代码点, mT标志着新的测试点。