How to effectively work with multiple files in Vim

前端 未结 28 2652
甜味超标
甜味超标 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:27

    Listing

    To see a list of current buffers, I use:

    :ls
    

    Opening

    To open a new file, I use

    :e ../myFile.pl
    

    with enhanced tab completion (put set wildmenu in your .vimrc).

    Note: you can also use :find which will search a set of paths for you, but you need to customize those paths first.


    Switching

    To switch between all open files, I use

    :b myfile
    

    with enhanced tab completion (still set wildmenu).

    Note: :b# chooses the last visited file, so you can use it to switch quickly between two files.


    Using windows

    Ctrl-W s and Ctrl-W v to split the current window horizontally and vertically. You can also use :split and :vertical split (:sp and :vs)

    Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l) to navigate through open windows.

    Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one.

    Starting vim with a -o or -O flag opens each file in its own split.


    With all these I don't need tabs in Vim, and my fingers find my buffers, not my eyes.

    Note: if you want all files to go to the same instance of Vim, start Vim with the --remote-silent option.

提交回复
热议问题