vi is a text editor tool used to create and modify contents of file.
Syntax: vi <filename>
Note: If file is already present it will open the existing file, which you can modify and if file is not present it will create a file with same name that you mention after it.
Below are the combination of keys which you need to press while working with vi editor. You first need to press Esc Key and then hold and press another Key such as i (to insert) and x (to delete).
Press Key | To Perform below action |
---|---|
Esc + i | Insert mode - used to type or modify contents. |
Esc + x | Delete one character (used if you are not in Insert mode). |
Esc + dd | Delete one line. |
Esc + 3dd | Delete 3 lines. |
Esc + 3yy | Copy 3 lines. |
Esc + p | Paste copied contents |
Esc + 3dd | Delete 3 lines. |
Esc + u | Undo last action. |
Esc + U | Undo last all actions. |
Esc + G | Moves cursor to the end of file. |
Esc + H | Moves cursor to the begining of file. |
Esc + A | Moves cursor end of line in Insert Mode. |
Esc + r | Replace one character. |
Esc + R | Replace mode - used to replace the contents. |
nano is also a good file editor tool used to create and modify contents of file.
Syntax: nano <filename>
Note: Once you are in nano editor - you just need to follow shortcut key that shows on your screen.