Sunday, February 14, 2016

Re: How can I do something whenever screen scrolled in vim?

> I want to vim to execute a shell command to notify Chrome whenever the
> screen has scrolled (after normal commands like <c-f> <c-b> <c-u> <c-d>
> etc.), but I could not find any event of autocmd to do that for me, is
> there any way I can do that?

There are two ways:

First, you can just override these mappings:

nnoremap <C-f> :call NotifyChrome()<CR><C-f>
nnoremap <C-d> :call NotifyChrome()<CR><C-d>
.. etc ..

Second, you could use the CursorMoved autocmd and some logic to see if the
visible area has changed. Untested:

autocmd BufReadPost myfile let b:store = [line("w0"), line("w$")]
autocmd CursorMoved myfile
\ if [line("w0"), line("w$")] != b:store
\| call NotifyChrome()
\| let b:store = [line("w0"), line("w$")]
\|endif

--
--
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/d/optout.

No comments: