1

I want to remap the ^ key to <Esc> in VIM since it is easier to reach on a german keyboard. As far as I understand there is no keycode for the ^ key and I have to use the termcap notation:

inoremap <t_*> <Esc>     " remap ^ to ESC
inoremap <C-t_*> <t_*>   " map CTRL-^ to the plain ^ (insert a '^' char)

But I could not find the termcap code for the circumlflex ^. Does anybody know a complete list of termcap codes for typical terminals. I want this solution to work for gvim in Ubuntu and Windows.

Edit: inoremap ^ <Esc> in Linux works partially. You have to press ^^. It only works perfectly if you use a non-dead-key layout. inoremap <C-^> ^ also does work fine with a non-dead-key layout but does not work at all with the default layout.

Solution: Use a keyboard layout that does not mute the ^ key and use the ^ (aka. circumflex or caret) as a std. ASCII character in your ~/.vimrc.

See superuser.com/questions/280005, how to disable dead keys in Windows. Thx Jens for the link.

Thx, Juve

Community
  • 1
  • 1
Juve
  • 10,584
  • 14
  • 63
  • 90
  • Do `inoremap ^ ` and `inoremap ^` work? – ib. Aug 26 '11 at 23:24
  • It works in Linux. But I am using a nodead-key layout there. I guess that makes the trick. In Windows I have a normal german layout where pressing `^` wont do anything until you press another key. There the `inoremap ^ ` does not work. – Juve Aug 27 '11 at 00:11

1 Answers1

1

The caret ^ is a regular ASCII character; it stands for itself and does not produce any termcap/terminfo sequence, so what you attempt with <t_*> is futile. Try to find out how to turn off dead keys on windows and you're done with ib's solution.

Jens
  • 69,818
  • 15
  • 125
  • 179
  • The ASCII char is produced when I press the `^` a second time. So I'd still be interested in the termcap code for the first `^` press. I thought every key has a termcap code, even the default ASCII chars? – Juve Aug 27 '11 at 23:39
  • Your understanding is incorrect. It's the keyboard driver that initially creates the sequence of characters an application receives. Only then is termcap/terminfo used to map these sequences to some action, e.g. the terminal sends OA for the UpArrow Key, and using termcap the application knows that the abstract function "Cursor Up" is requested. Dead keys are a lower level function of the X-Server/Windows-Keyboard Driver. – Jens Aug 28 '11 at 07:18
  • OK,I get it. So vim won't get any sequence until I press the second `^`. because the keyboard driver intercepts the first. – Juve Aug 28 '11 at 09:46
  • Right. Over on Superuser `dead-keys` is a tag :-) Maybe this thread will help you turning off dead keys: http://superuser.com/questions/280005/how-to-make-and-non-dead-keys-on-windows-7-with-german-keyboard-layout – Jens Aug 28 '11 at 09:56
  • Thx, for the link. My Windows at work is now also equipped with a non-dead caret. – Juve Aug 29 '11 at 08:42