8

I tried out gF and it seems to not behave like mentioned in :help gF

If cursor is positioned on an entry x.c and I type gf the file is opened.

If cursor is positioned on an entry x.c:3 and I type gF I get E447: Can't find file "x.c:3" in path. Whereby :3 should tell vim to jump to line 3.

What do I miss?

1
  • Works as expected for me. Check if there isn't any mapping in gF with :map gf Commented Apr 8, 2016 at 13:09

1 Answer 1

21

Enter :set isfname

It'll show an OS dependent list of all characters considered being possibly part of a file name. On my system (Windows), the column : appears in the list.

isfname=@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=

Hence it won't be considered by gF as a separator between file name and line number. However if I add a space between them, the behaviour goes as documented.

Given how no sane person uses : in a file name, if you want to use gF on some compiler's output that says file.c:120, you can add this to your vimrc :

set isfname-=:

(mind the - before the =)

If ever one day you need to open a file that has a : in its name, you can always enter :set isfname+=: to restore the column as a valid file name character for the duration of that session.

1
  • If you have to edit a file with :, just select it in visual and gf instead
    – CervEd
    Commented Mar 18, 2023 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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