Navigating long lines with Vim's built-in capabilities Vim can attempt to show long lines with :set wrap (on by default). With :set linebreak , Vim will wrap the lines at characters in 'breakat' ; this generally makes the text easier to read (in older versions of Vim, one will also have to :set nolist ).
zL Move the view on the text half a screenwidth to the right, thus scroll the text half a screenwidth to the left. This only works when 'wrap' is off. zH Move the view on the text half a screenwidth to the left, thus scroll the text half a screenwidth to the right.
You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E. Shift-Down will then scroll down (like moving a scroll-bar down, or like moving a cursor at the bottom of a window down), and Shift-Up will then scroll up (like moving a scroll-bar up, etc).
I use Vim to edit English text files with >10.000 words and long paragraphs. The files are formatted as plain text and each paragraph is a long line. I use the wrap
option, and I bind j
and k
to gj
and gk
respectively so I can move by display lines.
If my cursor is on the top of the screen (but not the beginning of the document) and I move the cursor up (using gk
), the screen scrolls up to display the whole long line (a 300-word paragraph). The problem is that because of the length of the line this makes the screen scroll by half of the screen. This is disorienting because I don't know beforehand how much the screen will move. Scrolling with ^Y
has the same problem.
Is there a way to make Vim scroll by just one display line when using gk
and its ilk? This is more natural for editing non-source-code and the default behavior in most text editors as well as in word processors, but not in Vim. I think this would mean that Vim would have to stop insisting on showing the entire line I'm editing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With