Error: E315, keepjumps, scrolloff

" To Reproduce:
" Add this file to plugins; start Vim.
" Open file A (eg. 100) lines and B (eg. 200) lines
" Do G on both files
" When switching from B to A (longer to shorter) the message
" It's a bug ... should appear (in :messages)
"
" The error caught is E315 on the line 'let toppos=line('.')
"
" The (funny) solution is:
"   let &scrolloff=&scrolloff
" (see the code below)

set scrolloff=3
function! ScrollOffBug()
   echom "ScrollOffBug?"
   " Solution:
   " let &scrolloff=&scrolloff
   try
      let pos = line('.')
      " error happens next:
      keepjumps norm! H
      let toppos = line('.')
    catch /.*/
       echom "It's a bug b=" . bufnr('%') . ", so=" . &scrolloff
    endtry
endfunc

au BufEnter * call ScrollOffBug()

-- 
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui