May 23rd, 2010
Understanding basic vi (visual editor)
Understanding basic vi (visual editor)
Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs.
Vim behaves differently, depending on the name of the command (the executable may still be the same file).
vim The “normal” way, everything is default.
ex Start in Ex mode. Go to Normal mode with the “:vi” command. Can also be done with the “-e” argument.
This first line is just to simply open a file with vi:
The following command is used to recover a file that was being edited when the system crashed:
The next command will open a file as read-only:
To move around in the editor
type h to type move the cursor to the left
type l to move it to the right
type k to move up
type j to move down
To search within VI
To search for text in vi you can use the “/” key followed by your search term. This example uses buddy:
To quit and not save changes you can use:
If you want to quit and save changes you can use the following command:
Reference : man vi command line