There are several forms of executing shell commands in vim:
1):!command
Do not exit vim and execute shell command commands to display the command output in the VIM command area without altering the contents of the currently edited file
Example:!ls-l
Special to run:!bash to launch a bash shell and execute commands without having to exit vim
2): R!command
Inserts the result of the shell command to the next line in the current row
For example: R!date, reads the system time and inserts the next line into the current row.
3): Start line number, end line number!command
Enters the contents of the range specified by the starting line number and end line number into the shell command handle and replaces the processing result with the contents of the range specified by the starting line number and ending line number
For example: 62,72!sort, sort the contents of rows 62 through 72
You can specify only the starting line, for example:!tr [A-z] [a-z], 62-line lowercase letters to uppercase
The current cursor line, in addition to specifying the line extra, you can also use., for example:. !tr [A-z] [a-z], the lowercase of the current line is capitalized
4): Start line number, end line number W!command
Enter the contents of the range specified by the starting line and end line numbers as the command. Does not change the contents of the currently edited file
For example: 62,72 w!sort, which sorts the contents of rows 62 to 72, but the results of the sorting are not directly exported to the currently edited file, but are displayed in the area of the VIM Strike Command
Special can be used under the following:!bash W, will be the 62nd line of content as a bash command to execute and display the results, and will not change the contents of the currently edited file
The same:. W!bash, executes the contents of the current line as a bash command
For example, 52 lines of content is ls-l
So input: The!bash is the same effect as executing!ls-l, if you're using a shell that's a bash shell
If the input is:!bash, then the 52nd line of the contents of the ls-l as a command execution, and the output of the command will replace the 52nd line of content, note the difference.
Execute Shell command Summary in VIM