Vim uses map ING to execute scripts

Source: Internet
Author: User

Recently, I started to pick up the C language. I will take a look at the C language as an example. Then I found that each time I wrote an example, I had to write a few characters to compile and execute it. Then I wanted to see if I could use vim's map ING, bind this conventional command to a shortcut key and check some information.
How to use it first.
Open ~ /. Vimrc file, and paste the code later:

Example

The code is as follows: Copy code

"Map c under the command line to compile and execute
Cmap! Gcc % &./a. out

Then save and close.

Open a new c file, write the C code, enter the command line mode, press ctrl + r, and then you can directly compile and execute the c file.

Next I will explain why I wrote this.

1. cmap refers to the ing under the command line. This ING does not take effect in other vim modes, so as to avoid conflicts. The usage is cmap {lhs} {rhs}. In the ing command mode, the key series {lhs} is mapped to {rhs }. The mapped {rhs} is also scanned for ING. This feature can be used for nesting and recursion of ING. Next, let's talk about the usage of other map types. nmap indicates normal mode, vmap indicates visual mode, imap indicates insertion mode, and default map indicates normal mode and visual mode.
2. ctrl + r
3.% indicates the current file in vim command line mode
4. Simulate press enter event
If you understand the principle, write some ing scripts that are helpful to you.

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.