Summary of executing shell commands in vim

Source: Internet
Author: User

Run the shell command in vim. The following forms are available ):! The command does not exit vim, and runs the shell command to display the command output in the vim command area. It does not change the content of the currently edited file, for example :! Ls-l special run :! Bash to start a bash shell and execute commands. Do not exit vim 2): r! Command inserts the shell command result into the next line of the current line, for example, r! Date: reads the system time and inserts it into the next row of the current row. 3): start line number, end line number! The command inputs the content in the range specified by the starting and ending line numbers to the shell command for processing, and replaces the content in the range specified by the starting and ending line numbers with the processing results, for example! Sort: sorts the content of rows 62 to 72. You can specify only the starting row, for example: 62! Tr [a-z] [A-Z], converts the lowercase letters of the 62 rows into the row where the current cursor is located, in addition to specifying the row number, can also be represented by., for example :.! Tr [a-z] [A-Z], converts lowercase of the current row to uppercase 4): Start row number, end row number w! Command uses the content of the range specified by the starting and ending line numbers as the command input. The content of the currently edited file is not changed, for example! Sort sorts the content from 62 rows to 72 rows, but the sorting result is not directly output to the file currently edited, it is displayed in the vim command-making area. It can be used as follows: 62 w! Bash, the content of Line 1 will be executed as a bash command and the result will be displayed, and the content of the file being edited will not change the same:. w! Bash: Execute the content of the current line as a bash command. For example, if the content of line 52 is ls-l, enter: 52 w! Execute bash! Ls-l has the same effect. If you use the bash shell, if the input is: 52! Bash, the contents of line 1, that is, ls-l, will be executed as a command, and the output result of the command will replace the contents of Line 2. Pay attention to the difference.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.