5

I know that gf will use includeexpr to modify the name and make another attempt to find said file. However I need to make two modifications to the term being used to seed the search (i.e., the text under the cursor when gf is pressed.

The Chef DSL on top of Ruby lets you include recipes from the same cookbook using this statement:

include_recipe ::foo

The underlying file is called foo.rb. So I need to strip off the leading colons, and tack on a .rb. One is easy, but I'm not sure how to do both.

:set includeexpr=substitute(v.fname,'::','','')

will remove the leading colons. How do I add the .rb?

1 Answer 1

3

You can concatenate v:fname with '.rb' inside substitute:

:set includeexpr=substitute(v:fname,'::\\(.*\\)','\\1.rb','')

EDIT:

I've changed it a bit, it appears that whitespaces after coma is not allowed.

3
  • I tried this but I get an "E518 Unknown option . " error. I tried "+" as a concatenation operator but that also failed. Nov 5, 2016 at 13:57
  • Your setup doesn't include the '::' in the file name, but mine appears to be doing that. Here's my isfname setting, I'm curious if yours is different: isfname=@,48-57,/,.,-,_,+,,,#,$,%,~,=,: Nov 6, 2016 at 3:19
  • Ah, I thought there is something like, mine was similar, but without :, cool - that's something I learned today :) I adjusted my answer to that
    – grodzik
    Nov 6, 2016 at 7:55

Your Answer

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

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