16

Is there a way to configure vim regarding what file types it considers "suitable" for opening?

Let me clarify by an example. Imagine you are working on a latex document. Once you build your file, you have the following in your directory (along with other files related to the build):

X.aux  X.log  X.out  X.pdf  X.tex

Now if you are working on another file (say Y.tex), and you want to :sp X.tex, you can use <Tab> to cycle through possible files, i.e.:

:sp X<Tab>

It seems that vim already makes a selection of what files you are most likely to want, and autocompletes to those files first. This is the order in which my vim is autocompleting files:

X.pdf
X.tex
X.aux
X.log
X.out

Again, it looks like vim has decided I probably want to open either the .pdf or .tex file and is presenting them to me first and in alphabetical order. Then it shows the rest of the files, again in alphabetical order. First, is my understanding correct?

If so, how can I tell vim that it shouldn't think I am interested in opening .pdf files with it? This way, the first <Tab> would immediately get me the .tex file as the file I am really looking for.

1 Answer 1

21

You can use wildignore, for example:

set wildignore+=*.pdf,*.o,*.obj,*.jpg,*.png

If you want to list them, but give low priority – list at end, one option is to use suffixes, for example with:

set suffixes+=.pdf

PDF files are going to be listed, but at the end of file list. Read up on :h suffixes with links for more detail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.