How to effectively work with multiple files in Vim

前端 未结 28 2671
甜味超标
甜味超标 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条回答
  •  感情败类
    2020-11-28 00:42

    I use the command line and git a lot, so I have this alias in my bashrc:

    alias gvim="gvim --servername \$(git rev-parse --show-toplevel || echo 'default') --remote-tab"
    

    This will open each new file in a new tab on an existing window and will create one window for each git repository. So if you open two files from repo A, and 3 files from repo B, you will end up with two windows, one for repo A with two tabs and one for repo B with three tabs.

    If the file you are opening is not contained in a git repo it will go to a default window.

    To jump between tabs I use these mappings:

    nmap  :tabprevious
    nmap  :tabnext
    

    To open multiple files at once you should combine this with one of the other solutions.

提交回复
热议问题