19

I have a big file with thousands of lines of thousands of characters.

I move the cursor to 3000th character.

If I use PageDown or Ctrl+D, the file will scroll but the cursor will come back to the first no-space character.

There's is an option to set to keep the cursor in the same column after a such scroll ?

I have the behavior with gvim on Window, vim on OpenVMS and Cygwin.

Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
Luc M
  • 16,630
  • 26
  • 74
  • 89

4 Answers4

29
CTRL-E - scroll down
CTRL-Y - scroll up

100<CTRL-E> will scroll down 100 lines for example

If you like using PageUp, PageDown or Ctrl+D etc. you can set the "nostartofline" option

:set nostartofline
Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
Philip Reynolds
  • 9,364
  • 3
  • 30
  • 37
7

Well, one easy way to do so is using the movement keys. For example, to go down 100 lines keeping the cursor at the same column: "100j"

Edit:

Alright, searching a little more to really find an answer to your question, there's an option to do exactly what you want:

:set nostartofline
skinp
  • 4,157
  • 4
  • 27
  • 20
  • 1
    You posted your answer 1-2 minutes after Phil. I had to choose. I choose the fastest. Thank you very much. – Luc M Feb 18 '09 at 15:55
3

A Recent Plugin

I am using terryma/vim-smooth-scrolling plugin as it provides a very nice and smooth scrolling.


To install, you can use Vundle:

Bundle terryma/vim-smooth-scrolling

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>
Mick
  • 30,759
  • 16
  • 111
  • 130
1

This might not suit your situation at all, but if it makes it easier to break the lines up you can break them at a certain character e.g. after ':'

:%s/:/\r&/g

Or every 80 characters

:%s/.\{80}/&\r/g
sparklewhiskers
  • 910
  • 8
  • 19