How may I scroll with vim into a big file?

可紊 提交于 2019-12-03 04:22:43

问题


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.


回答1:


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



回答2:


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



回答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>



回答4:


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


来源:https://stackoverflow.com/questions/561500/how-may-i-scroll-with-vim-into-a-big-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!