Tuesday, June 15, 2010

Re: Vim scroll option

Excerpts from Benny Bürger's message of Wed Jun 16 00:24:24 +0200 2010:
> Hi,
>
> I don't like extremly fast scrolling, so I want to reset the scroll variable
> to a lower value (Important when using <C-D> or <C-U>
> Unfortunately it is reseted each time a window is resized, this is quite
> annoying.
> I solved the problem by rebinding of the <C-D> and <C-U> keys
>
> nmap <C-D> 5j
> nmap <C-d> 5k

Behaviour differs slightly. You may want this instead:
nmap <C-D> 5j5<c-e>

How much lines do you want to scroll? Should the amount depend on screen
size as well? Eg be a 1/4th of screen height?

Have a look at the VimResized autocommand. You should use that.

I would have suggested using an autocommand. But Vim seems to set the
value after the autocommand was triggered..

augroup SCROLL
autocmd VimResized,BufEnter exec 'set scroll='.winheight(0)/4
autocmd VimResized,BufEnter * echoe 'set scroll='.winheight(0)/4
augroup end


So best you can do is

fun! Scroll()
exec 'set scroll'=winheight(0)/4
endf
nnoremap <c-d> :call Scroll()<cr><c-d>
nnoremap <c-u> :call Scroll()<cr><c-u>

which will set 'scroll' whenever you press c-d or c-u

Marc Weber

--
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

No comments: