Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-complete only filenames with bash when running vim?

Tags:

bash

vim

Is there some plugin for bash that will modify tab complete when I'm trying to open a file with vim? For example, if I have a directory with the following files:

  • foo/
  • foo.c
  • foo
  • bar.c
  • bar/

(where foo/ and bar/ are directories, and foo is a binary file)

and I do this:

vim f

and then hit tab, is there a way for the autocomplete to ignore the foo/ and foo binary files, and automatically fill it in with "foo.c", since that's the only text file that starts with f?

like image 580
user1516425 Avatar asked Nov 03 '22 19:11

user1516425


1 Answers

Yes! It's not really a plugin per se, but you can edit bash's autocomplete configuration file to match parameters for specific applications. On Debian-based systems, you'll find this configuration file at /etc/bash_completion.

In fact, there's a handy guide to modifying /etc/bash_completion over at Debian Administration. I'm sure you could modify filename completion to only accept non-binary files.

like image 108
David Cain Avatar answered Nov 11 '22 16:11

David Cain