In this video I will show you the basic commands necessary to edit files using the VI Editor. That is the editor that I use in most of my tutorials and there have been questions around how I performed some of the steps pertaining to updating files. Many times I don’t talk about the exact key commands I used and so in this video I will walkthrough very basic usage of vi for beginners or those people that need to follow my tutorials or just need to update some files but are not linux/unix experts. This is not meant to be a full comprehensive tutorial.
- Open Files
- Use ‘sudo’ for elevated privilege’s to the current users you are logged in with for system and configuration files.
- Quit vi without saving (:q!)
- Insert new line and add code (o)
- Exit out of Insert mode (esc)
- Insert mode without a new line added (i)
- Delete line (dd)
- Delete single character (x)
- Move cursor to the beginning of line or end of line ($, ^)
- Undo change (u)
- Redo change (ctrl+r)
- Exit the file without Saving (:q!)
- Search text inside a file
- type /
- enter text to search, enter
- type letter ‘n’ to find next line where occurance for the text is found
- Paste from clipboard
- enter paste mode, (:set paste)
- enter Insert mode (i)
- Shift+Insert to paste
- esc
- Paste sometimes also works with right-click
All videos tutorials on the website as well as the YouTube channel aim to provide a simplified process for a specific scenario; there could be many different factors and unique use cases you may have. The tutorials may not cover every situation; so treat is as a starting point or learning concept to apply to your unique situations, and consider this inspiration but not prescription or explicit direction.