|
|
|
|
|
Basics of vi that you must know |
---|
To enter the vi editor, type vi
on the command
line followed by a file name to create or open:
Produces a clear screen if it's a new file, with ~ running down the left side. You can get by with a very short list of commands (18 of them):
a, A: -append or append at end of line, and enter input mode Esc: -leave input mode, enter command mode x, dd: -delete a char, delete a line (in command mode only) h, l, j, k: -move left, right, up, down (in command mode only) ZZ: -save changes, exit vi (in command mode only) :w, :w filename: -write, write to "filename", no exit (in command mode) :q, :q!: -quit and don't save, quit and don't save even if changes (in command mode) /sometext: -search for "sometext" (in command mode) :23: -go to line 23 (in command mode) If in doubt, press "Esc". Then type ":q!" (to exit vi without saving changes), and start over.
|
Remember, in input mode (after an i, I, a, or A command), all key strokes except Esc become a character in the file.
"Command mode"
cursor movements:
other basic commands:
command line (sometimes called "ex mode"):
"Input Mode" - editing your code...