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

后端 未结 10 1479
遇见更好的自我
遇见更好的自我 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:55

    It's as simple as typing

    vim /dir1/file1 /dir2/file1 /dir2/file2 ...
    

    Once you're in vim, you can switch betwen then with ":n" to go to the next file, ":prev" to go to the previous file.

    0 讨论(0)
  • 2020-12-05 02:55

    Maybe this could help:

    http://vimdoc.sourceforge.net/htmldoc/windows.html

    0 讨论(0)
  • 2020-12-05 02:57

    You can use quickfix mode, as following

    :set errorformat=%f
    :cf myfilelist
    

    at this point you can use the normal quickfix shortcuts to go through your files, :cn for the next file, :cp for the previous one and :cr to go to the first again.

    EDIT:

    oh, if you want to read the list from the current buffer, use :cb instead of :cf in in the instructions above

    0 讨论(0)
  • 2020-12-05 02:59

    Try this with bash:

    $ vim -S <(sed "s/^/badd /" <your file name>)
    

    But I don't know why the first line of the file is ignored... :-O

    This script works as expected:

    rm -f myfile
    for i in `seq 10000`
    do
      touch $i
      echo $i >> myfile
    done
    vi -c "badd `head -1 myfile`" -S <(sed "s/^/badd /" myfile)
    

    http://vimdoc.sourceforge.net/htmldoc/starting.html#-S
    http://vimdoc.sourceforge.net/htmldoc/windows.html#:bad

    0 讨论(0)
提交回复
热议问题