I'm using GVIM under Windows. And want to map CAPSLOCK to Ctrl+^
Any way to do this?
Btw, I see tons of samples over the web how to swap CAPS and Esc using registry hack, but none of them use VIM map command, instead external tools and registry changes.
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.
Instead, when in insert mode, press Ctrl- ^ (hold down Ctrl and press ^ – the 6 key on US keyboards) to toggle "Caps Lock" on or off.
Linux? With X, use xmodmap to alter the key mapping, e.g.
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
Will map Esc to the CapsLock key. Google for more examples.
If your intention is just to avoid working outside of Vim, you can put these lines in your .vimrc:
au VimEnter * !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' au VimLeave * !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Caps_Lock'
The first line maps escape to the caps lock key when you enter Vim, and the second line returns normal functionality to caps lock when you quit.
This requires Linux with the xorg-xmodmap package installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With