James Franco
James Franco

Reputation: 4706

Vim command Scroll Up and down - Does a plugin exist for this?

I have been using vim for a couple of months now however my current workflow involves continuously scrolling down and up. For that i use Ctrl+f and Ctrl+b So whenever I use the Ctrl+f combination the new text appears on the center of the screen. I wanted to know if there was a way for vim to always have a light coloured line in the center of screen (so i could use the line as a reference to the new content whenever i press ctrl+f (scroll half screen)). I know this request sounds odd but I am curious if such a feature exists?

Upvotes: 1

Views: 376

Answers (2)

Put this in your .vimrc or in a script:

augroup HlMid
  autocmd!
  autocmd CursorMoved * :call HighlightMiddle() 
augroup END

function! HighlightMiddle()
  normal! M                                                           
  execute "match search /\\%".line('.')."l/"                          
  normal! ^O                                                          
endfunction!

EDIT: As rgoliveira stated in the comment that could interfere with match command. You need only to remove the autocommand and make it back whenever you use it:

Remove:

:autocmd! HlMid CursorMoved *

Reload:

:autocmd HlMid CursorMoved * :call HighlightMiddle()

For the last command in the function normal! ^o you get ^o by typing ctrl+v ctrl+o

Upvotes: 1

mechatroner
mechatroner

Reputation: 1350

You can try this smooth scroll plugin: https://github.com/terryma/vim-smooth-scroll I think it may solve your problem.

Upvotes: 1

Related Questions