Skip to content

Instantly share code, notes, and snippets.

@davejachimiak
Created February 12, 2013 13:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davejachimiak/4769993 to your computer and use it in GitHub Desktop.
Save davejachimiak/4769993 to your computer and use it in GitHub Desktop.
Mappings for opening related js.coffee file in rails.
" ...
function! OpenRelatedCoffeeFile(action)
let action = a:action
if match(expand('%'), 'app/assets') != -1
exec action . " " . expand("%:s?app/assets?spec?:s?.js.coffee?_spec.js.coffee?")
else
exec action . " " . expand("%:s?^spec?app/assets?:s?_spec??")
endif
endfunction
map <Leader>jv :call OpenRelatedCoffeeFile(":vsplit")<cr>
map <Leader>js :call OpenRelatedCoffeeFile(":split")<cr>
map <Leader>je :call OpenRelatedCoffeeFile(":e")<cr>
" ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment