
An Introduction to Display Editing with Vi USD:11-9
On rare occasions, your file may have nonprinting characters in it. These characters are displayed in the same
way they are represented in this document, that is with a two character code, the first character of which is ‘ˆ’. On
the screen non-printing characters resemble a ‘ˆ’ character adjacent to another, but spacing or backspacing over the
character will reveal that the two characters are, like the spaces representing a tab character, a single character.
The editor sometimes discards control characters, depending on the character and the setting of the beautify
option, if you attempt to insert them in your file. You can get a control character in the file by beginning an insert
and then typing a ˆV before the control character. The ˆV quotes the following character, causing it to be inserted
directly into the file.
4.2. Higher level text objects
In working with a document it is often advantageous to work in terms of sentences, paragraphs, and sections.
The operations ( and ) move to the beginning of the previous and next sentences respectively. Thus the command d)
will delete the rest of the current sentence; likewise d( will delete the previous sentence if you are at the beginning of
the current sentence, or the current sentence up to where you are if you are not at the beginning of the current sen-
tence.
A sentence is defined to end at a ‘.’, ‘!’ or ‘?’ which is followed by either the end of a line, or by two spaces.
Any number of closing ‘)’, ‘]’, ‘"’ and ‘´’ characters may appear after the ‘.’, ‘!’ or ‘?’ before the spaces or end of
line.
The operations { and } move over paragraphs and the operations [[ and ]] move over sections.†
A paragraph begins after each empty line, and also at each of a set of paragraph macros, specified by the pairs
of characters in the definition of the string valued option paragraphs. The default setting for this option defines the
paragraph macros of the −ms and −mm macro packages, i.e. the ‘.IP’, ‘.LP’, ‘.PP’ and ‘.QP’, ‘.P’ and ‘.LI’ macros.‡
Each paragraph boundary is also a sentence boundary. The sentence and paragraph commands can be given counts
to operate over groups of sentences and paragraphs.
Sections in the editor begin after each macro in the sections option, normally ‘.NH’, ‘.SH’, ‘.H’ and ‘.HU’,
and each line with a formfeed ˆL in the first column. Section boundaries are always line and paragraph boundaries
also.
Try experimenting with the sentence and paragraph commands until you are sure how they work. If you have
a large document, try looking through it using the section commands. The section commands interpret a preceding
count as a different window size in which to redraw the screen at the new location, and this window size is the base
size for newly drawn windows until another size is specified. This is very useful if you are on a slow terminal and
are looking for a particular section. You can give the first section command a small count to then see each succes-
sive section heading in a small window.
4.3. Rearranging and duplicating text
The editor has a single unnamed buffer where the last deleted or changed away text is sav ed, and a set of
named buffers a−z which you can use to save copies of text and to move text around in your file and between files.
The operator y yanks a copy of the object which follows into the unnamed buffer. If preceded by a buffer
name, "xy, where x here is replaced by a letter a−z, it places the text in the named buffer. The text can then be put
back in the file with the commands p and P; p puts the text after or below the cursor, while P puts the text before or
above the cursor.
If the text which you yank forms a part of a line, or is an object such as a sentence which partially spans more
than one line, then when you put the text back, it will be placed after the cursor (or before if you use P). If the
yanked text forms whole lines, they will be put back as whole lines, without changing the current line. In this case,
the put acts much like a o or O command.
Try the command YP. This makes a copy of the current line and leaves you on this copy, which is placed
before the current line. The command Y is a convenient abbreviation for yy. The command Yp will also make a
† The [[ and ]] operations require the operation character to be doubled because they can move the cursor far from where it currently is. While it
is easy to get back with the command ``, these commands would still be frustrating if they were easy to hit accidentally.
‡ You can easily change or extend this set of macros by assigning a different string to the paragraphs option in your EXINIT. See section 6.2 for
details. The ‘.bp’ directive is also considered to start a paragraph.