Postmaster Guidelines and Procedures

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 filename

- or -

from within the Mush mail program, type: ~v
if you accepted the default by pressing the Enter or Return key in response to the login prompt of:

Enter preferred editor [default is vi]:
All commands in VI begin to execute from the current position of the cursor.

In the following:

^ indicates that you hold down the key marked Ctrl or control while pressing the other indicated key
esc indicates that you press and release the key marked Esc and then press and release the other indicated key

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:

a append text beginning at current cursor position
i insert text prior to the current cursor position
A append text beginning at the end of the current line
I insert text beginning at the beginning of the current line

Canceling a command

If you begin a VI command and decide you do not want to proceed, type:
esc

Moving the cursor

To move the cursor, use, in EDIT mode:

j down one line
k up one line
l forward one character
h backward one character
0 beginning of line
$ end of line
^ f next screen
^ b previous screen
:$ move beginning of last line of file
:1 move to beginning of first list of file

Deleting text

In EDIT mode, to delete: Use:

one character
(character beneath cursor is removed)
x
one character
(character before cursor is removed)
^ h
one line dd
reminder of line D

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:

:%s/existing/new/c

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:

y change this instance, search for next match
n make no change
You can also use

:%s/existing/new/g

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:

esc n
where n is the number of times you want to repeat the command that follows
followed by the command you want to repeat.

For example, to move the cursor down 10 lines, you would use:

esc 10
^ n

Saving your work

To save what you have done, type:
^ x
and then type: s

Note: it is important that you avoid using:
^ s
because it can cause your screen to freeze. Should you inadvertently type it, you can frequently release the screen by using:
^ q


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:
^ x
followed by: ^ c
If you have not saved changes to the file, jove will ask if you want to save the changes before you exit. Type y to save them and exit, type n to exit without saving your changes.

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:
^ l
(that is a lower case letter L.)

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.
Mark the beginning of the selection by moving the cursor to its first chararacter and typing:
^ @
At the bottom of the jove window, jove will display [Point pushed].
Move the cursor one character after the last character you want in the text buffer and type:
^ w
to move the selected text to the buffer.
You can restore the contents of the buffer by using:
^ y
The text is restored at the current cursor location.

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:

^ x
followed by
(
(that is a left parenthesis.)
Any command(s) you type will be put into the macro.

To end the macro, use:
^ x
followed by
)
(that is a right parenthesis.)
To execute the macro, use:
^ x
followed by
e
(that is a lower case E.)
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:
esc <
type 5 spaces

start a macro with:
^ x
(
type the commands:
^ n
to go down one line

^ a
to move to the beginning of the line

type 5 spaces

end the macro with:
^ x
)
execute the macro with:
esc 1000
(or other large number to include all lines in the file)
^ x
e

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:
^ x
followed by:
^ w
At the bottom of the jove window, jove will prompt you for the name of the file in which you want to save your work. Type a file name and press the key marked Enter or Return. Jove save a copy of your work to the file name you have indicated.


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

 

 

****** Useful VI commands Command/Action Function /listname will take you to one of the entries for the list (you will need to change two) n moves you down one line k moves you up one line h moves you right one character l moves you left one character x deletes one character UNDER the cursor a appends characters after current position ESC gets you out of append !q quits without writing the file !wq writes the file and quits When this is complete, go to the domo login into lists and make certain the new owner is on the list! We do not remove the previous owner in most circumstances, as they can remove themselves. Do an ls -plas listname* in the domo/lists directory to see if the list is moderated (it will have a .approved file). If the list is moderated, change the moderator information to the new list owner. Send a message to the old owner with copy to the new owner, thanking them for letting you know that this was needed and asking the old owner to provide the new owner with the list password and list maintenance instructions. What if a list owner forgets his/her password? If the message is from the list owner, we look at the file listname.passwd on domo and tell them the password. Should a mailing list go to zero members, there may be a problem with the disk space. Notify network systems via voice: call until you get a person!!! Changing list configurations Any manual change to list ownership, moderation or configuration will involve your logging on to mail.virginia.edu with the id domo (same password as upostmst). After this logon, use cd lists to move to the directory where the lists are located. If you have created a list with multiple moderators or multiple owners, you will need to edit the file that contains the list members to put each list owner on a separate line and remove the commas. Edit the file whose name is the same as the listname. If you have created a list with multiple moderators, you will need to edit the file that contains the list moderators to put each list moderator on aseparate line and remove the commas. Edit the file whose name is listname.approved to do this. If you are changing a list from open to closed or adding/deleting private, you change these values by changing the parameters in the listname.config file. NOTE : If the list is configured as archived or digested, see the lead postmaster before making the change. You will know a list is digested if it has in the domo/lists directory, in addition to the regular list files (listname, listname.bak, listname.config, listname.info, and listname.passwd), it has files that begin with list-digest. You will know that a list is configured as archived if you do an ls archive and see its name as one of the archived lists. deleting a list changing a list name