Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is so complicated to remap Esc to CAPS LOCK in Vim?

Tags:

I saw the vim wiki tips and it says that in order to remap Esc to CAPS LOCK you have to edit the following windows code:

REGEDIT4 [HKEY_CURRENT_USER\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00 

Is it possible to remap Esc to CAPS LOCK by only adding or modifying lines in the _vimrc?

like image 934
alexchenco Avatar asked Jan 27 '10 06:01

alexchenco


People also ask

How do I remap Escape key Vim?

If you use Vim in a terminal, simply press alt/meta+normal_mode_key. Most terminals send an escape character followed by the normal_mode_key that you pressed, removing the need to press escape yourself. Thus in insert mode pressing alt+h alt+j alt+k alt+l all take you to normal mode and move in the expected direction.

What does Caps Lock do in Vim?

vim - Software Caps Lock : vim online. This plugin enables a software caps lock. This is advantageous over a regular caps lock in that normal mode commands, other buffers, and other applications are unaffected. The default mapping is <C-G>c but if you use this feature regularly, you will probably want a shorter one.


1 Answers

I recommend that you use AutoHotkey for this.

You can do a per-application hotkey change:

SetTitleMatchMode,2 #IfWinActive,VIM    CAPSLOCK::ESC return  #IfWinActive    CAPSLOCK::CTRL return 

This script, for example sets caps to escape in vim, and control everywhere else.

like image 151
Jay Avatar answered Jan 01 '23 22:01

Jay