What is the best way to do smooth scrolling in Vim?

后端 未结 10 1594
醉梦人生
醉梦人生 2021-01-30 03:01

The main scrolling commands in Vim are:

  1. Ctrl-B and Ctrl-F, as well as PageUp and PageDown scrol
相关标签:
10条回答
  • 2021-01-30 03:32

    A Recent Plugin

    I have posted something similar here, but basically there is a great plugin that we can use now for scrolling, called terryma/vim-smooth-scroll. It provides a very nice and smooth scrolling.


    The install is quite easy:

    1 I use Vundle so I simply appended this in .vimrc.bundles :

    Bundle terryma/vim-smooth-scroll
    

    In the latest version of Vundle available today, 29th April of 2016, you can put this in your .vimrc:

    Plugin 'terryma/vim-smooth-scroll'
    

    2 As stated in the doc, you can set up 3 arguments: distance, duration and speed.

    I am using this in my .vimrc file:

    noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 10, 4)<CR>
    noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 10, 4)<CR>
    
    0 讨论(0)
  • 2021-01-30 03:40

    I just found this plugin called "accelerated-smooth-scroll" ("Vim plugin for accelerated smooth scroll (mapping to <C-D>/<C-U>, <C-F>/<C-B>)") which can be for example used through Vundle by putting this line in your .vimrc:

    Plugin 'yonchu/accelerated-smooth-scroll'
    

    Then by restarting Vim and running the :PluginInstall command, then again restart Vim and use the <C-D> (Ctrl+D) and <C-O> (Ctrl+O) commands normally.

    Sadly, this plugin also moves the cursor instead of what I wanted: to just scroll the screen like the <C-E> and <C-Y> commands.

    0 讨论(0)
  • 2021-01-30 03:46

    There is a simple remap hack in vim's tips.txt:

    Smooth scrolling                    *scroll-smooth*
    
    If you like the scrolling to go a bit smoother, you can use these mappings:
    
        :map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
        :map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
    
    0 讨论(0)
  • 2021-01-30 03:47

    The Plugin cskeeters/vim-smooth-scroll supports smooth scrolling and requires no configuration. It supports to support smooth scrolling with zt, zz, and zb. It's a fork of terryma's plugin. Some of the open pull requests have been applied.

    0 讨论(0)
提交回复
热议问题