I want to open Test.txt file when I put the cursor on the word test.txt and type gf. Is it possible?
Asked
Active
Viewed 261 times
9
1 Answers
6
: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)
global
{not in Vi}
When set case is ignored when using file names and directories.
See 'wildignorecase' for only ignoring case when doing completion.
akshay
- 6,497
- 37
- 43
-
1Thank you for the answer but it didn't work. (E447: Can't find file "test.txt" in path) Here is my screencast: https://asciinema.org/a/30cc7yp6hhv4m38hh7qi6uem4 – npcode Feb 03 '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 03 '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 04 '16 at 00:25 -
4Conceptually, I don't think this is possible.
Consider: if you type
– David Oneill Feb 04 '16 at 14:41gfwhile pointing tofile.txtand the folder containsFile.txtandfile.TXT, which should it open? -
@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 09 '16 at 08:03
fileignorecasedoesn'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 gfand 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. – Borys Serebrov Feb 03 '16 at 18:02