Use the c. Vim plug-in to create a C/C ++ integrated Editor

Source: Internet
Author: User
ArticleDirectory
    • Step 1: Download C. Vim
    • Step 2: Install
    • Step 3: Enable this plug-in
    • Feature 1: Add automatic header to *. c file
    • Feature 2: Use "If to add a c Function
    • Feature 3: Use "IM to add the main function
    • Feature 5: Add annotation frame with "CFR
    • Feature 6: Use "P <to include header files
    • Feature 7: Save the compilation file.
    • Feature 8: Use "NR to insert a pre-defined code snippet
With the c. Vim plug-in, you can implement

    • Add File Header
    • Add Comment
    • Insert someCodeFragment
    • Syntax check
    • READ function documentation
    • Comment code block

This plug-in was prepared by Fritz mehner, with the goal of creatingProgramSmooth editing environment.
 
This plug-in can also be completed:

    • Statement oriented editing of C/C ++ programs
    • Speed up writing new Code considerably.
    • Write code and comments with a professional appearance from the beginning.
    • Use code snippets


Next we will introduce this plug-in detail.

3. Install the plug-in Step 1: Download C. Vim
 
$ CD/usr/src
$ Wget http://www.vim.org/scripts/download_script.php? Src_id = 1, 9679
Step 2: Install
 
$ Mkdir ~ /. Vim
$ Cd ~ /. Vim
$ Unzip/usr/src/cvim.zip
Step 3: Enable this plug-in
 
$ Vim ~ /. Vimrc
Filetype plugin on
8 C. Vim use feature 1: Add automatic header to *. c file

When you create a file with the extension. C, the header comment is automatically added to the file header.

$ Vim myprogram. c
/*
* ===================================================== ============
* Filename: myprogram. c
*
* Description:
*
* Version: 1.0
* Created: 01/19/20:23:25
* Revision: None
* Compiler: gcc
*
* Author: dr. Fritz mehner (Mn ),
Mehner@fh-swf.de
* Company: FH s zookeeper dwestfalen, iserlohn
*
* ===================================================== ============
*/


If you want to change the values of author and Company, you need to modify the template file ~ /. Vim/C-support/templates

 
$ Vim ~ /. Vim/C-support/templates
| Author | = geekstuff
| Authorref | = GK
| Email | = subscribe @ geekstuff
| Company | = thegeekstuff.com


Edit a new file to see if your author and company name have changed.

$ Vim myprogram. c
/*
* ===================================================== ============
*
* Filename: myprogram. c
*
* Description:
*
* Version: 1.0
* Created: 01/19/20:26:43
* Revision: None
* Compiler: gcc
*
* Author: geekstuff (Gk), subscribe @ geekstuff
* Company: thegeekstuff.com
*
* ===================================================== ============
*/

 

Feature 2: Use "If to add a c Function

Type "If + function name (as shown in fig1 below)" to automatically define the function in the file, as shown in figure 2.
 

 

Fig1: insert C function automatically
 

Fig 2: insert C function automatically

Feature 3: Use "IM to add the main function

The added results are as follows:

 

Fig 3: insert C main function automatically

Feature 4: Add function comments with "CFU"
 

 

Fig 4: insert C function header automatically
 

Fig 5: insert C function header automatically

Feature 5: Add annotation frame with "CFR

 

 

Fig 6: Insert a Frame Comment automatically

Feature 6: Use "P <to include header files

Type "P <in the normal mode, which will include the text" # include <> ", and places the cursor in the <symbol in insert mode where you can type the header file name.

Feature 7: Save the compilation file.

Save and compile the file "RC.

Run "RR.

Feature 8: Use "NR to insert a pre-defined code snippet

The plugin comes with few pre-defined code snippets that you can insert into your code. Following are the default code snippets that comes with the plugin.

 
$ LS ~ /. Vim/C-support/codesnippets
Makefile calloc_double_matrix.c main. c print_double_array.c.noindent
Makefile. multi-target.template calloc_int_matrix.c main. CC print_int_array.c.noindent

For example, if you want to create a function that will allocate a dynamic int-matrix of size rows * columns; return a pointer, you can re-use it from the existing code snippets. following is the content of the calloc_int_matrix.c pre-defined code snippets.

/*
* === Function ================================================= ==========================================
* Name: calloc_int_matrix
* Description: allocate a dynamic int-matrix of size rows * columns; return a pointer.
* ===================================================== ========================================================== ======
*/
Int **
Calloc_int_matrix (INT rows, int columns)
{
Int I;
Int ** m;
M = calloc (rows, sizeof (int *);/* allocate pointer array */
Assert (M! = NULL);/* abort if allocation failed */
* M = calloc (rows * columns, sizeof (INT);/* allocate data array */
Assert (* m! = NULL);/* abort if allocation failed */
For (I = 1; I
M [I] = m [I-1] + columns;
Return m;
}/* ---- End of function calloc_int_matrix ----*/


If you want to insert this code, you can enter the name of the NR file, and the code will be automatically inserted.

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.