Is there a way to get vim's gf command (or something similar) to recognize a +{cmd} argument for file-paths?One can start vim and go directly to a search term by doing:$ vim +/coding_effort ~/project/fileSimilarly, in command mode you can do::e +/coding_effort ~/project/fileI often take notes and refer to other files like this:For more info see +/coding_effort ~/project/file where there's a detailed discussion.I'd love to be able to select +/coding_effort ~/project/file, type something like gf, and have vim do the right thing.
Can I use gf (or similar) to open a file and jump to a search term?
key bindings;command line;search
No, the first problem is that the necessary space between command and filename is not part of the 'isfname' option, and adding it would mean file borders couldn't be recognized at all. You'd either have to always use a visual selection (of both command and filename), or implement custom parsing in a gf command overload.Secondly, the built-in gf doesn't recognize the +{cmd} syntax, so there's really no way around implementing your own custom mapping. This is certainly possible (using functions like expand('<cfile>'), getline(), etc.), but probably takes a few lines of Vimscript function.If you choose a different syntax (filename:+command), you can keep the original gf commands and implement the splitting in an :autocmd, similar to what the very related file:line plugin does for filespec:linenumber).