问题
I've written a Vimscript function - CoffeeScriptIncludeExpr - that when assigned to includeexpr, allows me to use gf to open a CoffeeScript file when the cursor is on its classname.
However, this doesn't work in a Rails project. My vimrc contains the following
autocmd User Rails.javascript.coffee* set includeexpr=CoffeeScriptIncludeExpr()
autocmd User Rails.javascript.coffee* set path=app/assets/javascripts/**
which I had hoped would have the desired effect.
If I type gf in a CoffeeScript file with the cursor on FooBar, vim prints an error message stating Can't find file 'foo_bar.rb' in path. Puzzlingly, typing set includexpr? shows it's set to CoffeeScriptIncludeExpr. Similarly for set path?. But the error message suggests vim-rails is running the show.
What do I need to do to get gf to work with my CoffeeScript files?
回答1:
It looks like vim-rails overrides the gf command; find out with :verbose nmap gf.
To undo this, remove the mapping with:
:autocmd User Rails.javascript.coffee* nunmap <buffer> gf
来源:https://stackoverflow.com/questions/15430440/how-do-i-override-gf-with-vim-rails