Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

This is a mirror of http://www.vim.org/scripts/script.php?script_id=4646

smooth.vim - Smooth animation of the cursor and the page whenever they move, with easing. By joeytwiddle, inspired by Terry Ma's smooth_scroll.vim, one of many Ctrl-U/Ctrl-D scrollers. Not to be confused with daylilyfield/sexyscroll.vim which lacks easing. I have not yet seen any other smooth-scrolling scripts that provide easing, operate on general movements, or use winrestview instead of keymappings/cursorhold.

Usually when you scroll the buffer or motion to a different part of the document, Vim will jump there immediately. But with Smooth, Vim will scroll to the new position smoothly. As well as looking pretty, this provides you with visual feedback about the distance you have travelled.

Options

Instead of specifying the scrolling speed, Smooth asks you to specify how slow you want scrolling to be. You can store these options in your .vimrc once you are happy with them.

Set the time it takes (in milliseconds) for the buffer to scroll one line or column.

:let g:Smooth_ScrollTime = 10

Set the time it takes for the cursor to travel one line. Probably only visible if you have :set cursorline. Set it to 0 to never animate the cursor.

:let g:Smooth_CursorTime = 5

(I like to pretend the cursor is "lighter" than the buffer.)

Set the maximum amount of time that longer scrolls can take:

:let g:Smooth_MaxTime = 500

Choose the easing style (how scrolling accelerates and decelerates):

:let g:Smooth_EasingStyle = 2

where

  • 1 = start fast, finish slowly (like 2 but less so)
  • 2 = start very fast, finish very slowly (recommended, default)
  • 3 = start slowly, get faster, end slowly (sexy)
  • 4 = start very slowly, end very slowly (like 3 but more so)
  • ? = constant speed (dull)

Interrupts the animation if you press a key. Resumes the animation if they key you pressed causes further scrolling, otherwise just jumps directly to the destination. Resuming animation looks best with EasingStyle 1.

:let g:Smooth_DetectPendingKeys = 1   /   0

This command is provided to enable/disable the scrolling:

:SmoothToggle

For eye candy, try MaxTime=1200, EasingStyle=3 and increase ScrollTime as well. This can help to visualise the distance travelled when moving through a document.

Power users may prefer to lower MaxTime to 400, and set EasingStyle 1 or 0. This will make Vim feel more like normal (more responsive).

Works pretty well in the general case, without having to configure custom mappings, but there are a few known issues which are documented in the script itself.

The most noticeable is that if you have 'hlsearch' enabled, scrolling does not occur until after you leave search mode! Although it works fine on n and N.

Older versions of the script may be found at https://github.com/joeytwiddle/sexy_scroller.vim

About

a vim plugin to smooth out scrolling

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages