Now we’ll introduce Execution Mode command so please type in colon (:) under Command Mode to enter in Execution Mode.
Execute external command without quitting from vi
:!< command >
Type in command line “:!bash” if for executing bash without quitting vi. Typing in exit can quit bash to go back vi.
For senior system administrator or programmer, such function can make user execute other programs or commands without quitting vi to massively improve work efficiency. For example, just type in “:!date” if for date information.
vi – Execution Mode (Import File Contents)
Example: :r /etc/passwd
The file contents will be imported after cursor without using Append Redirection.
vi – Execution Mode (Import Command Output)
The output of date command will be imported after cursor.
Save as new file:
:w< file name >
Like Windows notepad, it will stay in original text editing after saving text as new file.
Compulsive symbol (!):
:q! – quit without saving
:w! – Force to save without modifying access permission if user has file modification but no access permission
:wq! – Force to save and quit without modifying access permission if user has file modification but no file access permission