Skip to content

Instantly share code, notes, and snippets.

@devguydavid
Created February 13, 2013 00:26
Show Gist options
  • Save devguydavid/4780119 to your computer and use it in GitHub Desktop.
Save devguydavid/4780119 to your computer and use it in GitHub Desktop.
" Smooth Scroll
"
" Remamps
" <C-U>
" <C-D>
" <C-F>
" <C-B>
"
" to allow smooth scrolling of the window. I find that quick changes of
" context don't allow my eyes to follow the action properly.
"
" The global variable g:scroll_factor changes the scroll speed.
"
"
" Written by Brad Phelan 2006
" http://xtargets.com
"
" Changelog:
" Modified by David Brown 02-2013 http://davtar.org
" * Uses sleep isntead of a while(1) loop
let g:scroll_factor = 2
function! SmoothScroll(dir, windiv, factor)
let sleeptime = g:scroll_factor * a:factor . "m"
let wh=winheight(0)
let i=0
while i < wh / a:windiv
let i = i + 1
if a:dir=="d"
normal j
else
normal k
end
redraw
"sleep l:sleeptime
exe 'sleep ' . sleeptime
endwhile
endfunction
map :call SmoothScroll("d",2, 2)
map :call SmoothScroll("u",2, 2)
map :call SmoothScroll("d",1, 1)
map :call SmoothScroll("u",1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment