|
To vi a file |
- Open the file
- > vi filename
|
|
To close the file |
- After you've entered the file with vi, you have options for
closing
- To close without saving
- > :q
-
- To close and save
- > :wq
-
- To force any command use !
- To close and force the save
- > :wq!
|
|
To end any VI command |
|
|
To insert text |
- place the cursor where you want to insert the text to the
left
> type i
- to append text after the cursor
> type a
- to open a line below the cursor (insert a new line)
> type o
- to open a line before the cursor
> type O
|
|
To undo |
- the last change to the file.
> type u
|
|
To Delete |
- To delete a character, place cursor before the desired text.
> type x
- continue typing x to delete as many characters as desired
- or -
- to delete from the cursor to the end of the line
> type D
- To delete an entire line. Place cursor on that line
> type dd
- To delete multiple lines. Place cursor on the 1st line to
be deleted
> type #dd
- where # is the number of lines to be deleted
- To delete a word. Place cursor on the word
> type dw
|
|
To replace text |
- To enter replace mode, place cursor at begining of text to
be replaced
> type R
- To replace a character, place cursor before the character
> type rx
- where x is the character being added
- To replace a word, place cursor before the character
> type cw
-
- To replace the CASE of a letter
> type -
|
|
To fix a broken line |
Sometimes a line that should be a continous line gets broken.
The easiest way to fix this is to put the cursor at the break
and press shift + j. Then remove any extra space that may have
been created. |