Let’s face it! The VI text editor for Linux can be quite intimidating. This post shows the most commands to help even the newest of vi / vim user survive. This is not the full list of vi commands, but these will help you whilst you are getting familiar with it. Alternatively, visit http://glaciated.org/vi/ for the full manual.
To open a file in vi, type:
Then use any of the following commands:
|Command||General Save & Exit Controls|
|:x||Save & Exit|
|:q||Exit, No changes|
|:q!||Exit, Ignore changes|
– Both ‘:w’ and ‘:x’ requires you to have write permissions.
|Command||Insert Text & Lines|
|i||Insert at the cursor|
|I||Insert before the line|
|a||Append text after the cursor|
|A||Append text after the line|
|o||Create a new line|
– Each of these commands puts the vi into insert mode.
– Press the <Esc> key to put vi back into command mode.
– The ‘i’, ‘a’ and ‘o’ command supports undo if you press the * key.
|Command||Delete Text and Lines|
|D||Delete the remainder of the line, from the cursor|
|dd||Delete the current line|
– The command ‘dd’ supports undo if you press the * key.
|G||Move the end of the file|
|Left Arrow Key||Move left|
|Right Arrow Key||Move right|
|Up Arrow Key||Move up|
|Down Arrow Key||Move down|
– You can also use: ‘j’ for down, ‘k’ for up, ‘h’ for left and ‘l’ for right.
What is VI / VIM Editor?
VI / VIM is the default text editor that is provided on the Linux platform. It can be quite intimidating to
Don’t like VI/VIM editor?
You could always install Nano text editor and save yourself the effort of learning vi editor.
To install Nano text editor on Debian or Ubuntu machines:
sudo apt-get install nano
To install the Nano text editor on CentOS or RHEL based platforms
sudo yum install nano
You could also try other text editors! Read this article about an alternative text editor called: Micro.
Using VI becomes super easy once you have the “keys to the kingdom”! ;-) I hope you liked this post. If so, please click the like button and you will receive a million years of good Luck! Feel free to read other great posts at https://anto.online/.