Table of Contents
Linux - Vi
Introduction
To edit files on the command line, you can use an editor such as vi. To open the file, run
vi /path/to/file
The contents of the file must appear.
The file is created if it does not exist yet.
Articles Related
The most important commands
The most important commands in vi are these ones:
| Command | Description | Mode |
|---|---|---|
| i | enter in the Insert mode. It enable you to type in your text. | Normal Mode |
| ESC | leave the Insert mode press | Insert Mode |
| x | delete the character that is currently under the cursor | Normal Mode |
| :x | save the file | Normal Mode |
| :w | write the file | Normal Mode |
| :q | leave the file | Normal Mode |
| :q! | leave the file without saving the changes | Normal Mode |
Please note that you can use your keyboard's arrow keys to navigate the cursor through the text.
How to edit a file with Vi?
Then when you want to edit a file, the logical sequence is:
- to tape i to enter in Insert Mode
- to made the modifications
- to press the ESC button to leave the insert mode and to enter in a normal mode
- and save the file by entering the command :x