6

Occasionally, when writing shell scripts and such, I have entries of the form:

foo=/bar/baz

To get filename completion (<C-x> <C-f>) to work, I have to put a space after the =, and then remove it after completion. I don't have any filenames which contain =, so I don't care about it being part of the completion. How do I get it to work with the =? I use Linux primarily, but Windows on occasion too.

muru
  • 24,838
  • 8
  • 82
  • 143

2 Answers2

12

The list of valid filename characters is given by the isfname variable. From :he 'isfname':

'isfname' 'isf'     string  (default for MS-DOS, Win32 and OS/2:
                         "@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,="
                        for AMIGA: "@,48-57,/,.,-,_,+,,,$,:"
                        for VMS: "@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~"
                        for OS/390: "@,240-249,/,.,-,_,+,,,#,$,%,~,="
                        otherwise: "@,48-57,/,.,-,_,+,,,#,$,%,~,=")

To make Vim ignore = as a filename character, remove = from this list:

:set isfname-==

Now, completion should work for foo=/ba....

muru
  • 24,838
  • 8
  • 82
  • 143
4

Another option is to enclose the filename in quotes:

foo="/bar/baz"

Then file completion (<C-x> <C-f>) works after the first ".

pete-may
  • 41
  • 2