How may I scroll with vim into a big file?

2019-03-09 07:34发布

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.

4条回答
smile是对你的礼貌
2楼-- · 2019-03-09 08:15

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>
查看更多
Rolldiameter
3楼-- · 2019-03-09 08:28

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
查看更多
Deceive 欺骗
4楼-- · 2019-03-09 08:31

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
查看更多
Lonely孤独者°
5楼-- · 2019-03-09 08:32
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
查看更多
登录 后发表回答