In vi, how do I set up line-wrapping and do paragraph filling?
Line-wrapping is done through the use of a variable in vi called
wrapmargin. While in vi, to set up line-wrapping, press
Esc, then type:
:setwrapmargin=8
This will make the text you're typing wrap to the next line when it is
eight letters from the right-hand side of the screen.
To set vi to always wrap text by default, edit or create a file called
.exrc in your home directory, and add the following line:
set wrapmargin=8
If you would like to reformat a paragraph after adding or deleting
text from it, move the cursor to the beginning of the paragraph and
enter the following:
ESC!}fmt
This calls fmt, an external program, to reformat the text.
If you are
on a System V Unix computer, you can substitute a different command by
entering:
ESC!}adjust -m70
To set up the letter q to do paragraph filling
automatically, add the following line to your .exrc: file:
map q !}fmt^M
To type ^M, press Ctrl-v , then press
Enter.
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
Last modified on August 22, 2008.







