Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2008 · complexity basic · author Benshi · version 7.0
It can be convenient to use the numeric keypad when you need to enter a lot of numbers. However, your keyboard may not have a keypad, or you may not want to move your hands from the home row.
The following script allows you to switch Vim to a special "VimLock" mode (like pressing the Num Lock key). In this mode, pressing keys on the home row (a, s, d, ...) will generate digits (1, 2, 3, ...) rather than letters. Press Escape to exit from VimLock mode.
Put the following in your vimrc:
nnoremap <C-I> :call VimLock(1)<CR>i function! VimLock(enable) if a:enable inoremap a 1 inoremap s 2 inoremap d 3 inoremap f 4 inoremap g 5 inoremap h 6 inoremap j 7 inoremap k 8 inoremap l 9 inoremap ; 0 inoremap <Esc> <Esc>:call VimLock(0)<CR> else iunmap a iunmap s iunmap d iunmap f iunmap g iunmap h iunmap j iunmap k iunmap l iunmap ; iunmap <Esc> endif endfunction
Now you can press
Ctrl-i to enter insert mode and map the keys "
a s d f g h j k l ;" to the digits "
1 2 3 4 5 6 7 8 9 0". Pressing
Esc will end this mode and restore the letter keys. Since
Ctrl-i is Tab, you can just press the Tab key to enter VimLock mode.
The mappings assume a QWERTY US keyboard where the
; key is on the right of
L. If necessary, change
; to suit your keyboard.