我已经开始使用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(但不是原始的Vi!)有制表符,我发现(在许多情况下)比缓冲区更好。你可以说:table [filename]在新选项卡中打开一个文件。标签之间的循环是通过点击标签或组合键[n]gt和gt来完成的。graphic Vim甚至有图形标签。
其他回答
当在vim中使用多个文件时,我主要使用这些命令(打开了大约350个文件):
:b <partial filename><tab>(跳转到缓冲区) :bw(缓冲区擦除,删除缓冲区) :e <文件路径>(编辑,打开一个新的缓冲区> . Pltags -允许跳转到子例程/方法定义
To open 2 or more files with vim type: vim -p file1 file2 After that command to go threw that files you can use CTRL+Shift+↑ or ↓ , it will change your files in vim. If u want to add one more file vim and work on it use: :tabnew file3 Also u can use which will not create a new tab and will open file on screen slicing your screen: :new file3 If u want to use a plugin that will help u work with directories and files i suggest u NERDTree. To download it u need to have vim-plug so to download other plugins also NERDTree to type this commands in your ~/.vimrc.
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
call plug#end()
然后通过命令:wq保存.vimrc,返回并输入::PlugInstall
之后,插件将被安装,你可以使用你的NERDTree与其他插件。
如果你要使用多个缓冲区,我认为最重要的事情是 设置隐藏 这样它就能让你切换缓冲区即使你要离开的缓冲区中有未保存的更改。
When I started using VIM I didn't realize that tabs were supposed to be used as different window layouts, and buffer serves the role for multiple file editing / switching between each other. Actually in the beginning tabs are not even there before v7.0 and I just opened one VIM inside a terminal tab (I was using gnome-terminal at the moment), and switch between tabs using alt+numbers, since I thought using commands like :buffers, :bn and :bp were too much for me. When VIM 7.0 was released I find it's easier to manager a lot of files and switched to it, but recently I just realized that buffers should always be the way to go, unless one thing: you need to configure it to make it works right.
所以我尝试了vim-airline,并启用了可视的顶部选项卡式缓冲条,但图形与我的iTerm2有问题,所以我尝试了其他几个,似乎MBE最适合我。我还设置shift+h/l作为快捷键,因为原来的那些(移动到当前页面的头部/尾部)对我来说不是很有用。 map <S-h>:bprev<返回> map <S-l>:bnext<返回>
它似乎比gt和gt更简单,而且:e也比:tabnew更简单。我发现:bd不像:q那样方便,虽然(MBE有一些问题),但我可以在缓冲区中使用所有文件。
我使用了多个隐藏在~/中的缓冲区。vimrc文件。
迷你缓冲区资源管理器脚本也很好,可以获得缓冲区的紧凑列表。然后:b1或:b2…要转到适当的缓冲区或使用迷你缓冲区资源管理器并通过缓冲区使用TAB。