home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeLearning the vi EditorSearch this book

2.4. More Ways to Insert Text

You have inserted text before the cursor with the sequence:

itext to be insertedESC

You've also inserted text after the cursor with the a command. There are other insert commands for inserting text at different positions relative to the cursor:

A
Append text to end of current line.

I
Insert text at beginning of line.

o
Open blank line below cursor for text.

O
Open blank line above cursor for text.

s
Delete character at cursor and substitute text.

S
Delete line and substitute text.

R
Overstrike existing characters with new characters.

All of these commands place you in insert mode. After inserting text, remember to press ESC to escape back to command mode.

A (append) and I (insert) save you from having to move your cursor to the end or beginning of the line before invoking insert mode. (The A command saves one keystroke over $a. Although one keystroke might not seem like much of a saving, the more adept—and impatient—an editor you become, the more keystrokes you will want to omit.)

o and O (open) save you from having to insert a carriage return. You can type these commands from anywhere within the line.

s and S (substitute) allow you to delete a character or a whole line and replace the deletion with any amount of new text. s is the equivalent of the two-stroke command c SPACE and S is the same as cc. One of the best uses for s is to change one character to several characters.

R ("large" replace) is useful when you want to start changing text, but you don't know exactly how much. For example, instead of guessing whether to say 3cw or 4cw, just type R and then enter your replacement text.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.