The notation you're using for CTRL-]
doesn't work in that context. The command you're using will act as though you had typed the following five keystrokes in normal mode: <C-]>
In order to invoke the CTRL-]
functionality, use the following instead:
:execute "normal! \<C-]>"
(See :help :execute
and :help string
for more details of how this works.)
As an aside, if the code you've pasted is in your vimrc
, it won't have the effect you're aiming for, of creating a mapping that doesn't apply to the elixir filetype.
The code in your vimrc is run when Vim is starting up before the file is opened: at that time, 'filetype'
will never be set to elixir
, and thus the mapping will always be created.
One simple way to fix this is to move the filetype check into the mapping:
function! JumpDef()
if &filetype != "elixir"
execute "normal! \<C-]>"
endif
endfunction
nnoremap <C-]> :call JumpDef()<CR>