|
|
Hints on using the text editor VI |
|---|
| Hints on using the text editor VI | |||||||||||||||||||||||||||
| Common editing tasks |
Getting Started Adding new text Canceling a command Moving the cursor Deleting text Searching for text Replacing text Repeating a command Saving your work Exiting jove Refreshing the screen Using the jove text buffer Creating a macro Saving your work to a new filename |
||||||||||||||||||||||||||
| Getting Started |
To invoke vi on either the mailhub (mail.virginia.edu) or list.mail.virginia.edu
computer, you can:
from the command line, type: vi filenameAll commands in VI begin to execute from the current position of the cursor. In the following:
|
||||||||||||||||||||||||||
| Adding new text |
When VI begins, you are in edit mode; VI is expecting you to provide a command. To add new text to the file, use one of the following commands:
|
||||||||||||||||||||||||||
| Canceling a command |
If you begin a VI command and decide you do not want
to proceed, type:
|
||||||||||||||||||||||||||
| Moving the cursor |
To move the cursor, use, in EDIT mode:
|
||||||||||||||||||||||||||
| Deleting text |
|
||||||||||||||||||||||||||
| Searching for text |
To locate a specific text string in a file, beginning
at the current cursor position and searching toward the
end of the file, use:
At the bottom of the VI window, you will be prompted for the text for which you want to search. Enter the text, press the key marked Enter or Return. From the current cursor position, VI will search the file to its end for the specified text and will leave the cursor positioned at the first character of the instance of the text found. To search from the current cursor position toward the beginning of the file, use:
|
||||||||||||||||||||||||||
| Replacing text |
To search for text and have it replaced with other text, use the
following:
As soon as you type the :, the cursor moves to the bottom of the VI window. After the c, press the key marked Enter or Return. From the current cursor position, VI will search the file to its end, for the specified text and will leave the cursor positioned at the first instance of the text found. VI will query you for what action you want to take. Use:
to replace the existing text with the new text from the current cursor position to the end of the file. Should you use this form of the command, be cautious: if you tell VI to substitute the with an, VI will change all the's, including those found as a part of a word, for example, there | ||||||||||||||||||||||||||
| Repeating a command |
To repeat a command, type:
where n is the number of times you want to repeat the command that followsfollowed by the command you want to repeat. For example, to move the cursor down 10 lines, you would use:
|
||||||||||||||||||||||||||
| Saving your work |
To save what you have done, type:
Note: it is important that you avoid using:
When you save, at the bottom of the jove window, jove will tell you how many lines and characters are in the file. If the file has not changed since the last time you saved, at the bottom of the jove window, jove will tell you that there are no changes to make. |
||||||||||||||||||||||||||
| Exiting jove |
To leave jove, type:
If you have saved the changes you have made to the file, jove will exit the file. |
||||||||||||||||||||||||||
| Refreshing the screen |
To refresh your screen, type:
|
||||||||||||||||||||||||||
| Using the jove text buffer |
Jove offers the capability to place selected text into
a buffer that can be recalled. This capability is often
used when copying, moving or removing selected text.
|
||||||||||||||||||||||||||
| Creating a macro |
Using a macro is a way to have jove remember one or more commands that you want to use repeatedly. To define a macro, use: Any command(s) you type will be put into the macro. To end the macro, use: To execute the macro, use: For example, to insert 5 spaces at the beginning of every line in a file, you could: go to the beginning of the file with:type 5 spaces |
||||||||||||||||||||||||||
| Saving your work to a new filename |
To save your work to a file that has a different name than the file you are editing, use the command:
|
|
Intro | Abuse
| Aliases | Failed
Mail | Help & Contact Info | Jove Hints | Lists |
Massmail | mboxes | Reading the Postmaster's Mailbox | Registration | Too Large | VI Hints | Viri | Tips and Tricks |