Question

I have a custom "go to definition" shortcut that works great in python (using ropevim) but when I'm in a coffee-script file I need to use the normal ctags lookup to navigate around. Would it be possible to make just one shortcut that did either a ropevim lookup OR a ctags lookup depending on the file type that is open in the current buffer?

Was it helpful?

Solution

You can put if/endif tests in your mappings by way of :execute but that's a bit messy.

What you should do instead is define your mappings in filetype-specific autocmds (see :h autocmd):

autocmd FileType python nnoremap this that

or, better, define them in ~/.vim/after/ftplugin/python.vim (and another file for coffeescript and so on):

nnoremap <buffer> this that
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top