List of useful functions in VI
| Commands |
Descriptions |
| a |
Append text from current position |
| i |
Insert text from current position |
| x |
Delete a single character from current position |
| dd |
Delete a single line from current position |
| / |
Start a search by entering the search string after the / . When the / is pressed again , the same search string can be looked for again by just pressing enter |
| ? |
Search backwards from current point |
| :q |
Quits from the editor |
| :w |
Saves the current changes to the files |
| :wq |
Writes and then quits from the editor |
| :q! |
Quits without saving changes/the file |
| 1G |
Jump to the top of the file |
| G |
Jump to the bottom of the file |
| yy or Y |
Copy line to paste |
| p |
Paste after cursor |
| P |
Paste before cursor |
| ~ |
changes the case on the highlighted character (note: while not in edit mode)
|
| cw |
change word - sit on the first letter of a word, type cw, this will change the last letter of the word to a $ to indicate the ending of the selected word, type the replacement word and press ESC to change |
| r |
Changes a character that is currently highlighted with the cursor with a character entered by the user |
| :%s!^!cp ! |
This inserts cp infront of every line. Simply replace cp with any text that needs to be insterted in front of every line |
| :line number |
This shows line numbers against each line of text in the file open in VI |
|