There are many ways to edit files in Unix and for me one of the best ways is using screen-oriented text editor vi. There is an improved version of vi also called vim (vi improved).
Starting the vi editor:
Command | Description |
---|---|
vi filename | Creates a new file if it already does not exist, otherwise opens existing file. |
vi -R filename | Opens an existing file in read only mode. |
Operation Modes:
vi has two modes of operation
- Command mode: This mode enables you to perform administrative tasks such as saving files, executing commands, moving the cursor, cutting (yanking) and pasting lines or words, and finding and replacing. In this mode, whatever you type is interpreted as a command.
- Insert mode: This mode enables you to insert text into the
file. Everything that's typed in this mode is interpreted as input and
finally it is put in the file .
Hint: If you are not sure which mode you are in, press the Esc key twice, and then you'll be in command mode. You open a file using vi editor and start type some characters and then come in command mode to understand the difference.
vi cheatsheet:
No comments:
Post a Comment