Home Explore Blog CI



neovim

5th chunk of `runtime/doc/usr_25.txt`
5f65fe1e8960ab76b2b43e702648372d1bdeda6cacccc53f0000000100000e18

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, personalized letter to  |
	|their richest 1000 customers.    |
	|Unfortunately for the programmer,|
	+---------------------------------+
<
Related options:
'breakat' specifies the characters where a break can be inserted.
'showbreak' specifies a string to show at the start of broken line.
Set 'textwidth' to zero to avoid a paragraph to be split.


MOVING BY VISIBLE LINES

The "j" and "k" commands move to the next and previous lines.  When used on
a long line, this means moving a lot of screen lines at once.
   To move only one screen line, use the "gj" and "gk" commands.  When a line
doesn't wrap they do the same as "j" and "k".  When the line does wrap, they
move to a character displayed one line below or above.
   You might like to use these mappings, which bind these movement commands to
the cursor keys: >

	:map <Up> gk
	:map <Down> gj


TURNING A PARAGRAPH INTO ONE LINE			*edit-paragraph-join*

If you want to import text into a program like MS-Word, each paragraph should
be a single line.  If your paragraphs are currently separated with empty
lines, this is how you turn each paragraph into a single line: >

	:g/./,/^$/join

That looks complicated.  Let's break it up in pieces:

	:g/./		A ":global" command that finds all lines that contain
			at least one character.
	     ,/^$/	A range, starting from the current line (the non-empty
			line) until an empty line.
		  join	The ":join" command joins the range of lines together
			into one line.

Starting with this text, containing eight lines broken at column 30:
>
	+----------------------------------+
	|A letter generation program	   |
	|for a bank.  They wanted to	   |
	|send out a special,		   |
	|personalized letter.		   |
	|				   |
	|To their richest 1000		   |
	|customers.  Unfortunately for	   |
	|the programmer,		   |
	+----------------------------------+
<
You end up with two lines:
>
	+----------------------------------+
	|A letter generation program for a |
	|bank.	They wanted to send out a s|
	|pecial, personalized letter.	   |
	|To their richest 1000 customers.  |
	|Unfortunately for the programmer, |
	+----------------------------------+
<
Note that this doesn't work when the separating line is blank but not empty;
when it contains spaces and/or tabs.  This command does work with blank lines:
>
	:g/\S/,/^\s*$/join

This still requires a blank or empty line at the end of the file for the last
paragraph to be joined.

==============================================================================
*25.5*	Editing tables

Suppose you are editing a table with four columns:

	nice table	  test 1	test 2	

Title: Line Breaks, Paragraph Joining, and Editing Tables in Vim
Summary
This section covers the 'linebreak' option for displaying long lines with breaks, the use of 'breakat' and 'showbreak' options, and how to move by visible lines using "gj" and "gk" commands. It also details joining paragraphs into single lines with the ":g/./,/^$/join" command and adjusting it for blank lines. Lastly, it begins to discuss editing tables in Vim.