smoothPageScroll.vim : smooth page scroll
script karma |
Rating 20/8,
Downloaded by 1714 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Hosup Chung |
|
script type |
utility |
|
description |
Yet another smooth page scroll implementation.
I found scrolling the number of winheight() is not always correct, because the file could have wrapped lines. Let's say if your window height is 40, but you only see 35 actual lines because you have 5 wrapped lines. Then by scrolling the number of winheight(), 5 lines would be over-scrolled. This script won't skip the extra lines for having wrapped lines.
This script also emualtes one of VIM's normal <PageDown> or <PageUp> behaviors: which is to display first or last 2 lines from the previous screen after scrolling, unless it reaches first or last line, or the current window is showing 3 lines or less.
See other implementation - vimscript #1601, :help scroll-smooth |
|
install details |
Install:
Copy this script in your plugin directory
Usage:
1) call them directly
:call SmoothPageScrollDown() to scroll page down
:call SmoothPageScrollUp() to scroll page up
2) or remap <PageDown> and <PageUp>
map <PageDown> :call SmoothPageScrollDown()<CR>
map <PageUp> :call SmoothPageScrollUp()<CR>
Personally, I remapped <Space> and <S-Space> keys, since <Space> in non-insert mode is not that useful (just move the cursor one position right). And many programs such as web browsers or acrobat reader use space key to scroll page.
map <Space> :call SmoothPageScrollDown()<CR>
map <S-Space> :call SmoothPageScrollUp()<CR>
But remapping <S-Space> may not work on certain console or platform. So you might have to find another candidate, such as <M-Space>, <C-Space> or something else.
If the scrolling speed is too fast, you can delay scrolling speed more by adding g:smooth_page_scroll_delay in your [._]vimrc. Following line will delay extra 5 milliseconds per each line.
let g:smooth_page_scroll_delay = 5 |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 3.141.199.214
|