I want to open Test.txt file when I put the cursor on the word test.txt and type gf. Is it possible?

  • I think fileignorecase doesn't work because it only affects vim internal behavior and when it tries to open a file, the OS decides and plays by own rules. You can try to define the 'includeexpr' or redefine the default with :map gf and write an expression of function which will try all the combinations (like Test.txt, tEst.txt, teSt.txt, tesT.txt, TEst.txt and so on), but I am not sure if it worth the effort trying to do so. – Boris Serebrov Feb 3 '16 at 18:02

:set fileignorecase will treat file names and directories as case insensitive.

It's on by default for some systems like OS X which comes built in with a case insensitive (but case preserving) file system.

You can also read the help on it for more:

'fileignorecase' 'fic'  boolean (default on for systems where case in file
                 names is normally ignored)
                 {not in Vi}

    When set case is ignored when using file names and directories.
    See 'wildignorecase' for only ignoring case when doing completion.
  • 1
    Thank you for the answer but it didn't work. (E447: Can't find file "test.txt" in path) Here is my screencast: asciinema.org/a/30cc7yp6hhv4m38hh7qi6uem4 – npcode Feb 3 '16 at 14:33
  • @npcode hmm weird. Those exact steps seem to work fine for me. But maybe because I'm on OS X, Vim seems to work fine when the case doesn't match. I'll try it on Linux. – akshay Feb 3 '16 at 15:19
  • @npcode yes I see the problem on Linux. It seems that Vim won't open the file if the case does not match since most file systems on Linux are case sensitive. Maybe you could modify this somehow with :help includeexpr'. Or maybe post on the vim-dev mailing list to see what they say. – akshay Feb 4 '16 at 0:25
  • 4
    Conceptually, I don't think this is possible. Consider: if you type gf while pointing to file.txt and the folder contains File.txt and file.TXT, which should it open? – David Oneill Feb 4 '16 at 14:41
  • @DavidOneill I think there may be some possible options in the case: 1. Open all of them. 2. Open anyone with notice message. 3. Ask the user to choose one. – npcode Feb 9 '16 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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