Insert-mode only Caps Lock
From Vim Tips Wiki
Tip 1183 Previous Tip • Next Tip
Created: March 23, 2006 Complexity: basic Author: Gerald Lai Minimum version: 5.7 Karma: 8/2 Imported from: Tip#1183
This is a hack to provide CAPS Lock functionality only within these situations, so you don't have to turn the CAPS Lock off whenever you return to Normal mode:
- Insert mode
- Command-line mode
- when entering a search pattern
- the argument of the commands that accept a text character, such as "r" and "f"
- for the input() line
First, place the mappings below into your vimrc. Then, to toggle the CAPS Lock in *Insert mode*, hit Ctrl-6 (i.e., hold down Ctrl and press 6) instead of the _real_ Caps Lock key.
lnoremap a A lnoremap b B lnoremap c C lnoremap d D lnoremap e E lnoremap f F lnoremap g G lnoremap h H lnoremap i I lnoremap j J lnoremap k K lnoremap l L lnoremap m M lnoremap n N lnoremap o O lnoremap p P lnoremap q Q lnoremap r R lnoremap s S lnoremap t T lnoremap u U lnoremap v V lnoremap w W lnoremap x X lnoremap y Y lnoremap z Z lnoremap A a lnoremap B b lnoremap C c lnoremap D d lnoremap E e lnoremap F f lnoremap G g lnoremap H h lnoremap I i lnoremap J j lnoremap K k lnoremap L l lnoremap M m lnoremap N n lnoremap O o lnoremap P p lnoremap Q q lnoremap R r lnoremap S s lnoremap T t lnoremap U u lnoremap V v lnoremap W w lnoremap X x lnoremap Y y lnoremap Z z
[edit] References
[edit] Comments
The alternate Caps Lock provided by this tip is NOT effective while in Normal mode (i.e., after hitting Esc in Insert/Visual mode).
The advantage is that this alternate Caps Lock, once activated, only works in modes where it "really matters", like while you're typing/replacing in Insert mode, or inputting something into the :cmd-line. Langmapping is Vim's way of achieving such a task, because it is mode-specific.
If you do insist on doing _without_ langmaps, there is a suggestion of using AutoHotKey in the comments of VimTip1083 (that was provided as a reference). I can't say that this is very portable across different platforms.
If you are using this tip, but still wish to disable the alternate Caps Lock when pressing Esc, you could do
:inoremap <silent><Esc> <Esc>:set imi=0<CR> :vnoremap <silent><Esc> <Esc>:set imi=0<CR>
