How to effectively work with multiple files in Vim

前端 未结 28 2842
甜味超标
甜味超标 2020-11-28 00:18

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:

<
28条回答
  •  猫巷女王i
    2020-11-28 00:29

    I use the following, this gives you lots of features that you'd expect to have in other editors such as Sublime Text / Textmate

    1. Use buffers not 'tab pages'. Buffers are the same concept as tabs in almost all other editors.
    2. If you want the same look of having tabs you can use the vim-airline plugin with the following setting in your .vimrc: let g:airline#extensions#tabline#enabled = 1. This automatically displays all the buffers as tab headers when you have no tab pages opened
    3. Use Tim Pope's vim-unimpaired which gives [b and ]b for moving to previous/next buffers respectively (plus a whole host of other goodies)
    4. Have set wildmenu in your .vimrc then when you type :b + Tab for a buffer you will get a list of possible buffers that you can use left/right arrows to scroll through
    5. Use Tim Pope's vim-obsession plugin to store sessions that play nicely with airline (I had lots of pain with sessions and plugins)
    6. Use Tim Pope's vim-vinegar plugin. This works with the native :Explore but makes it much easier to work with. You just type - to open the explorer, which is the same key as to go up a directory in the explorer. Makes navigating faster (however with fzf I rarely use this)
    7. fzf (which can be installed as a vim plugin) is also a really powerful fuzzy finder that you can use for searching for files (and buffers too). fzf also plays very nicely with fd (a faster version of find)
    8. Use Ripgrep with vim-ripgrep to search through your code base and then you can use :cdo on the results to do search and replace

提交回复
热议问题