Execute Shell command Summary in VIM

Source: Internet
Author: User

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

Related Article

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.