Monday, April 8, 2013

Forcing myself to learn vim properly

begin:vcard
fn:Flavius Aspra
n:Aspra;Flavius
adr:;;;;;;AT
email;internet:flavius.as@gmail.com
x-mozilla-html:FALSE
url:http://flavius.github.com/
version:2.1
end:vcard

Hi

While learning vim the hard way, I was also playing around with scripting and I
was wondering of a way to enforce the avoidance of repeatedly pressing movement
keys, instead of using a count<movement>.

Having a code like this:

let g:cursor_moving = 0

function! TrapMovementKeys(key)
augroup CursorMoving
autocmd!
autocmd CursorMoved * let g:cursor_moving += 1
augroup END
if g:cursor_moving <= 2
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
autocmd!
autocmd CursorHold * let g:cursor_moving = 0
augroup END

which kind of works. The problem is though that CursorHold won't be triggered
while recording a macro (which is the documented behavior).

Now I am wondering if there is any workaround for this. Ideas?

Regards,
Flavius

--
What I cannot create, I do not understand. -- Feynman

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: