vim CTRL-] keys not working

Viewed 28248

Hi I'm new to vim and I'm stuck. In :help tag it says that one can go to a tag definition using the CTRL-] keystroke. But I can't get this to work. I thought I messed some mappings with my plugins, so I cleaned .vimrc. But I still get cursor to a tag word (in help for example). I strike Ctrl and ] simultaneously and nothing happens.

Does anybody know how to fix it? Or maybe I'm reading :help wrong?

9 Answers

The problem is due to default setting of Virtual box. In Oracle Virtual Box you can see by default right control is using as Host key combination. Go to File -> Preferences-> Input and change Host key combination to "None". Initially for me also left ctrl worked and after the above changes both keys working.

For mee, "Ctrl-]" means "Ctrl+Alt GR+)". In other words,

  • Press "Ctrl"
  • Press "Alt GR" while "Ctrl" is pressed
  • Press ")" ("]" is also there) while the two above are pressed

This solution only works for linux in an X environment for non-us keyboard layouts.

I just struggled with this problem in linux with a swiss german keyboard layout. We type ] by pressing AltGr+¨, thus i would have to use AltGr+Ctrl+¨ to jump to the ctag definition, which is awkward.

What i did was to remap the ¨ (diaeresis) key to ] (bracketright)

  1. print current mapping for keycode 35:

    $> xmodmap -pke | grep 35 keycode 35 = dead_diaeresis exclam dead_diaeresis exclam bracketright dead_macron bracketright

  2. remap key (we just replace the first dead_diaeresis with bracketright):

    $> xmodmap -e 'keycode 35 = bracketright exclam dead_diaeresis exclam bracketright dead_macron bracketright'

Pressing keycode 35 (¨) will now print ] without the need of any modifier, and CTRL-] works to jump to the tag.

xmodmap -e can be executed as user without need for sudo, you can put it for example in your .profile.

see swiss-german layout for reference

I had this same problem and I solved it. In my case I was maping the key CTRL + F10. So I First hit CTRL + F10 in Vim insert mode and see what the key output is. In my case it was F36 then I simply map it in vimrc file as

map <F36> <CR>YOUR COMMAND<CR>

With macOS on a Norwegian keyboard: CTRL-] is CTRL-å

Related