Chapter 11 Dealing with Text Files
Automatic Text Wrapping
:set textwidth=30 : Vim automatically inserts line breaks
:set wrapmargin=10
:set textwidth=70
(:set textwidth=0 means use default value 80)
which means you have a screen that is 80 characters wide, but you at most can have 70 characters in one line
Bad Thing:
if you delete something from one line, all you get is a short line!
How to get the paragraph into shape:
1.
a) select the paragraph as part of visual selection
b) execute gq command
2.
a) gq<motion> command: like gq4j which means formating 5 lines starting from the current line
3.
a)position the cursor on the first line of the paragraph
b)gq} command (no need to count the lines)
(this method has a risk: it will merge many paragraphs into one paragraph, suck! ANSWER: if you have a empty line between each paragraphs, it will work perfectly! Wonderful!)
4.
a)gqip (ip means inner graph, no need to put the cursor on the beginning of a paragraph)
****************************************************
Each paragraph should be separated by an empty line!
****************************************************
Text Formatting Command
:range center width ---> :1,5 center 30 (I haven't understood what width means)
:1,5 right 30
:range left margin ---> :1 left 5 :2,5 left 0
Movement
) command: moves forward one sentence
( command: does the same thing backward
} command: moves forward one paragraph
{ command: moves one paragraph backward