Created
March 14, 2013 10:18
-
-
Save dahu/5160260 to your computer and use it in GitHub Desktop.
HJKL repetition trap for Vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" HJKL repetition trap | |
" Barry Arthur, 2013-03-14 | |
" depends on your :help 'updatetime setting | |
let g:cursor_moving = 0 | |
function! TrapMovementKeys(key) | |
augroup CursorMoving | |
au! | |
autocmd CursorMoved * let g:cursor_moving = 1 | |
augroup END | |
if ! g:cursor_moving | |
return a:key | |
else | |
return '' | |
endif | |
endfunction | |
nnoremap <expr> h TrapMovementKeys('h') | |
nnoremap <expr> j TrapMovementKeys('j') | |
nnoremap <expr> k TrapMovementKeys('k') | |
nnoremap <expr> l TrapMovementKeys('l') | |
augroup CursorMovingOff | |
au! | |
autocmd CursorHold * let g:cursor_moving = 0 | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment