Reputation: 155
I like using the file browser in gvim sometimes, however what I don't like is that the file filter is always set to the current file type being edited.
For example, if I have a .cpp file open in the current buffer and go to the file open dialog the file filter is set to "C++ source files (*.cpp *.c++)". I would prefer that headers are displayed too by default (say).
Is there a way to change this default behavior?
Upvotes: 5
Views: 1451
Reputation: 513
If anyone, like me, wants a quick and simple way to disable this behaviour altogether in vimrc:
autocmd FileType * let b:browsefilter = ''
From first reply in this thread
Upvotes: 3
Reputation: 19
I had a similar issue that I solved without having to copy the c.vim file to ~/.vim/ftplugin
. To support *.cc as a C++ extension, in GVim on Ubuntu I edited the /usr/share/vim/vim74/ftplugin/c.vim
file to add the extension:
let b:browsefilter = "C++ Source Files (*.cpp *.c++ *cc)\t*.cpp;*.c++;*.cc\n" .
\ "C Header Files (*.h)\t*.h\n" .
\ "C Source Files (*.c)\t*.c\n" .
\ "All Files (*.*)\t*.*\n"
Then restarted GVim and it worked without copying c.vim
.
Upvotes: 0
Reputation: 155
Thanks to @benjifisher, I found the help for :browse
which shows how to do what I wanted.
More specifically, the default filetype plugin for C/C++ contains these lines:
let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
\ "C Header Files (*.h)\t*.h\n" .
\ "C Source Files (*.c)\t*.c\n" .
\ "All Files (*.*)\t*.*\n"
I copied the file into my local vim ftplugin
directory and modified to my liking which now takes precedence over the system version.
Upvotes: 4