(Author: Sherman Chen)
Method 1
========
:set textwidth=78
gggqG
"gg" takes you to the first line, "gq" is the format operator and "G" the motion that jumps to the last line.
Method 2
========
:set textwidth=78
:1,$g/.*/normal jgwap
Method 3
========
1. :set linebreak
to recover those broken words at the end of each line into whole words.
2. :set textwidth=78
3. Find a line which is longer than 78 characters, say line #3. Move the cursor to that line minus one, i.e. 3 - 1 = 2.
4. qaj$aa Backspace Escape q
5. See how many lines the file contains totally, say, 100.
6. gg
7. 100@a Enter
All the lines will become 78 character long now.
Method 4 (which has improved Method 3)
========
1. :set linebreak
to recover those broken words at the end of each line into whole words.
2. :set textwidth=78
3. Move the cursor to any line which is longer than 78 characters.
4. qa$aa Backspace Escape q
5. :%normal @a
All the lines will become 78 character long now.
(END)
No comments:
Post a Comment