Marius Roets wrote:
Hi everybody,
Can somebody explain the following behaviour to me. In my .vimrc I put
the following:
" ------START ----------
function ResizeEvent()
  let &lines = &lines - 1
  execute '!echo "resizing "'.&lines . ' >> test.txt'
endfunction

autocmd VimResized * call ResizeEvent()
" -------- END -----------
Now for every resize event, I get 4 lines in test.txt. The result is
that I end up with 'lines' being decreased 4 times, instead of just
once.

Thanks
Marius


Strange: normally autocommands don't nest, which would mean that using ":let &lines = &lines - 1" (or ":set lines-=1") inside an autocommand (for VimResized) shouldn't trigger VimResized again.

I confirm this strange behaviour: after sourcing a script containing

function ResizeEvent()
        set lines-=1
        redir >> ~/resize.log
        silent echo "lines:" &lines
        redir END
endfunction
au! VimResized * call ResizeEvent()

then invoking (once) ":call ResizeEvent()" at the gvim command-line, I get the following in ~/resize.log (which previously didn't exist):

<quote>

lines: 35
lines: 34
lines: 33
lines: 33
lines: 32
</quote>

Which OS and Vim version (and patchlevel) are you using? I'm using openSUSE Linux 10.2 and the output of ":version" starts as follows:

VIM - Vi IMproved 7.0 (2006 May 7, compiled Mar  8 2007 18:29:45)
Included patches: 1-214
Compiled by [EMAIL PROTECTED]
Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):
(etc.)


Best regards,
Tony.
--
Conceit causes more conversation than wit.
                -- LaRouchefoucauld

Reply via email to