Home Explore Blog CI



neovim

4th chunk of `runtime/doc/usr_25.txt`
14738d02e83a31b58f16f962380e397906abe638278129800000000100000fa4
 command: >

	:set tabstop=3
	:retab 8

The ":retab" command will change 'tabstop' to 8, while changing the text such
that it looks the same.  It changes spans of white space into tabs and spaces
for this.  You can now write the file.  Next time you edit it the indents will
be right without setting an option.
   Warning: When using ":retab" on a program, it may change white space inside
a string constant.  Therefore it's a good habit to use "\t" instead of a
real tab.

==============================================================================
*25.4*	Dealing with long lines

Sometimes you will be editing a file that is wider than the number of columns
in the window.  When that occurs, Vim wraps the lines so that everything fits
on the screen.
   If you switch the 'wrap' option off, each line in the file shows up as one
line on the screen.  Then the ends of the long lines disappear off the screen
to the right.
   When you move the cursor to a character that can't be seen, Vim will scroll
the text to show it.  This is like moving a viewport over the text in the
horizontal direction.
   By default, Vim does not display a horizontal scrollbar in the GUI.  If you
want to enable one, use the following command: >

	:set guioptions+=b

One horizontal scrollbar will appear at the bottom of the Vim window.

If you don't have a scrollbar or don't want to use it, use these commands to
scroll the text.  The cursor will stay in the same place, but it's moved back
into the visible text if necessary.

	zh		scroll right
	4zh		scroll four characters right
	zH		scroll half a window width right
	ze		scroll right to put the cursor at the end
	zl		scroll left
	4zl		scroll four characters left
	zL		scroll half a window width left
	zs		scroll left to put the cursor at the start

Let's attempt to show this with one line of text.  The cursor is on the "w" of
"which".  The "current window" above the line indicates the text that is
currently visible.  The "window"s below the text indicate the text that is
visible after the command left of it.

			      `|<-- current window -->|`
		some long text, part of which is visible in the window ~
	ze	  `|<--	   window     -->|`
	zH	   `|<--     window     -->|`
	4zh		  `|<--	   window     -->|`
	zh		     `|<--     window	 -->|`
	zl		       `|<--	window	   -->|`
	4zl			  `|<--	   window     -->|`
	zL				`|<--	 window     -->|`
	zs			       `|<--	window	   -->|`


MOVING WITH WRAP OFF

When 'wrap' is off and the text has scrolled horizontally, you can use the
following commands to move the cursor to a character you can see.  Thus text
left and right of the window is ignored.  These never cause the text to
scroll:

	g0		to first visible character in this line
	g^		to first non-blank visible character in this line
	gm		to middle of screen line
	gM		to middle of the text in this line
	g$		to last visible character in this line

		`|<--	  window     -->|`
	some long    text, part of which is visible in one line ~
		 g0  g^    gm	   gM g$


BREAKING AT WORDS				*edit-no-break*

When preparing text for use by another program, you might have to make
paragraphs without a line break.  A disadvantage of using 'nowrap' is that you
can't see the whole sentence you are working on.  When 'wrap' is on, words are
broken halfway, which makes them hard to read.
   A good solution for editing this kind of paragraph is setting the
'linebreak' option.  Vim then breaks lines at an appropriate place when
displaying the line.  The text in the file remains unchanged.
   Without 'linebreak' text might look like this:
>
	+---------------------------------+
	|letter generation program for a b|
	|ank.  They wanted to send out a s|
	|pecial, personalized letter to th|
	|eir richest 1000 customers.  Unfo|
	|rtunately for the programmer, he |
	+---------------------------------+
<
After: >

	:set linebreak

it looks like this:
>
	+---------------------------------+
	|letter generation program for a  |
	|bank.  They wanted to send out a |
	|special,

Title: Dealing with Long Lines, Scrolling, and Line Breaks in Vim
Summary
This section continues explaining dealing with long lines in Vim, focusing on the use of the ":retab" command for adjusting tabstops, and the horizontal scrolling of text when the 'wrap' option is off. It details the use of "zh", "zl", "zH", "zL", "ze", and "zs" commands for scrolling, and the commands "g0", "g^", "gm", "gM", and "g$" for moving the cursor within the visible text. Lastly, it introduces the 'linebreak' option for better display of long lines by breaking them at appropriate places while leaving the file unchanged.