Vi Editor is most popular editor in UNIX. vi editor is also called as Visual editor. Below methods describes different vi editor commands from basic to advance.
vi editor modes.
- Command mode: used for giving commands to editor
- Insert mode: used for entering the data into the file.
Now How to switch between these two modes:
Press “i” for INSERT mode now to return it to command mode press Esc button.
Vi editor commands.
This method describes the vi editor commands regards to opening & viewing the files in UNIX.
- # vi ===> Will open editor
- # vi <file> ===> Will open the file
- # view <file> ===> Will open the file as read-only
2. Save / Exit
This method describes the vi editor commands regards to saving & exiting the files in UNIX.
- :q ===> Will exit the editor
- :w ===> Will save
- :w <file> ===> Will save as
- :wq ===> Will save and exit
- “:x” ===> Same as above
- ZZ ===> Same as above
- :q! ===> Will exit forcefully without saving
- :w! ===> Will save forcefully
3. Switch between vi editor modes.
With this method of vi editor commands we can switch between the Vi editor modes .
- i ===> go to INSERT mode
- Insert ===> Same as above
- Esc ===> return to COMMAND mode
- v ===> go to VISUAL mode
Leave a Reply