How can I remap the ctags hotkeys?

The main hotkeys are Ctrl-] to jump to a definition, Ctrl-t to go back, then there are also commands, for example :ts lists the definitions for the last tag.

Rather than using the vulcan nerve pinches, I was thinking I might remap these commands to leader keys. But am not sure exactly how to do this. I know how to do regular mappings, but have not mapped plugin hotkeys before. Do I just do it like this:

nnoremap <Ctrl-]> <leader-a>

or something like that? How do I remap the ex commands?


There are q few misconceptions here:

  1. "Hotkey" is not a thing in Vim. You have "commands", "mappings", "abbreviations"… but no "hotkeys". <C-]>, <C-t> and :tselect are all "commands".

  2. There's no such thing as "leader keys". You can create and use "leader" mappings that use the "leader key", if you want, but there's nothing special with them.

  3. Ex commands are not "mappings" so you can't "remap" them.

Now, what's wrong with your mapping?

  1. The order:

    It's supposed to be {map command} {what you want to press} {what you want to happen} but you did {map command} {what you want to happen} {what you want to press}.

  2. The key notation:

    You used <Ctrl-]> instead of the correct <C-]> and <leader-a> instead of the correct <leader>a.

This is what your mapping should look like:

nnoremap <leader>a <C-]>

If you want to create a "leader mapping" for :ts you can do it like that:

nnoremap <leader>s :tselect<CR>

See :help key-notation and :help mapping.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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