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.