how to open a file in a list of files in vim?

后端 未结 10 1520
遇见更好的自我
遇见更好的自我 2020-12-05 02:22

I have a longish list of files opened in vim that looks like this:

/dir1/file1
/dir2/file2
/dir2/file3
.....

How can I open all of them one

10条回答
  •  盖世英雄少女心
    2020-12-05 02:54

    I'm going to assume you have the file list open inside Vim, and want to simulate the "gf" command across the whole list...

    Edit your .vimrc to include this function:

    function Openall()
        edit 
        bfirst
    endfunction
    

    You can then highlight the entire file (or the set of paths you want to open) using visual mode (1G, Shift-V, G) and typing ":call Openall()". Afterwards the command row will show this:

    :'<,'>call Openall()
    

    This will run the new Openall() function across all highlighted lines.

    Press Enter and all the files will be opened in background buffers. You can then access them using the usual buffer commands. :ls will display them as a list.

提交回复
热议问题