Executing shell commands in the VIM editor

Source: Internet
Author: User
Executing shell commands in the VIM editor

The 11th Chapter VI and VIM text editors for Linux commands, editors, and shell programming, this chapter will briefly describe how to edit text using the VI and VIM editors. This section describes the execution of Shell commands in the Vim editor.

11.7.5 execute shell commands in the VIM editor

Sometimes you need to execute a shell command in the Vim editor, such as the need to verify that a shell command is correct for writing to a script, and that you need to reference the input of a shell command in a file. This section provides a brief description of how to execute shell commands in the Vim editor.

(1) When executing a separate shell command in the Vim editor, you need to add ":!" before the command. For example, executing the shell command ":!ls-l" in vim command mode, the VIM editor will display the output of the command, as shown in Figure 11.27.

Figure 11.27 Executing the shell command in the VIM editor

As you can see from Figure 11.27, VIM will display the output of the command. If the user needs to return to edit the file, you can press the ENTER key.

(2) Sometimes you may need to refer to the output of the shell command in the file edited by the editor, and you can match the command ": R". For example, to read the output of the Ls-l command to the currently edited file, you can use ": R!ls-l". The VIM editor then reads the output of the command and inserts it into the currently edited file.

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.