Search code examples
vim

How to list the open files in vim and quickly traverse the list?


Currently I sometimes run vim with a wildcard, e.g. like this:

vim *.cpp

This works well, as I can then use :next and :prev to look at each of the .cpp files in sequence.

Where it falls down a little bit is when there are many files matching the wildcard, and I want to skip past several dozen/hundred of them quickly. E.g. typing :next 96 times in a row isn't much fun.

So my question is, is there some keystroke or command that will cause vim to list out all of the files that matched the wildcard-expansion, and allow me to "jump" directly to a file in the list, without having to laboriously :next my way down to it?


Solution

  • To list all of the open files:

    :ls
    

    to go to a particular file, use :[count]b. eg, to go to the file listed as number 6 from :ls, do :

    :6b