If you can remember all the cryptic commands within the Vi text editor on Linux then you are some kind of genius. For us mere mortals, the quickest way to edit files on Linux is to bin off Vi and move over to Nano. There, I said it, get over it. Nano is better than Vi hands down.
But in the unfortunate event you need to do a bit of Vi work before you can move over to Nano, for example to configure a network configuration file or to configure a Yum repositories configuration file for example, then you need to know how to work with Vi so you can get through that painful process as quick as possible.
Here are some handy Vi commands;
- Open a file: vi filename.txt
- Edit the file – aka. go into ‘insert mode’: Press the letter ‘i’ once you have opened the file
- Change what ever you need to do as usual
- Exit from Insert Mode: Press ESC
- Prepare to exit the file: Press colon :
- Now save and exit the file: Press, wq, then enter
- Whoops I messed up: Within Vi there are so many commands that seem to just utterly break the editor unless you know what they do that is can be difficult to exit out of the thing. If in doubt press ESC or CTRL + Q or CTRL + C and you should get back to where you need. Then exit the file without saving by pressing, :, q!, enter
I mean, simple, right?!?! Anyhow, that’s how you quickly edit the files you need and recover from when Vi has gone a bit crazy.
Latest posts by Michael Cropper (see all)
- How to Use the Vi Text Editor on Linux Guide for Humans - May 18, 2020
- How to Install Nano Editor on CentOS 7 - May 18, 2020
- Handy Database Design for Records to Track Created Date Time and Updated Date Time - April 2, 2020