![]() ![]() You can also build your own code snippets from the existing code – select the part of code need to be made as code snippet, press \nw, and give a file-name to it. Note: You can define your own code snippets and place it under ~/.vim/c-support/codesnippets/. To insert this into your working c program, type \nr from the normal mode inside vim, which will prompt “read snippet /home/ramesh/.vim/c-support/codesnippets/”, type calloc_int_matrix.c at the end and press enter, which will insert the content of the ~/.vim/c-support/codesnippets/ calloc_int_matrix.c to your working file automatically. } /* - end of function calloc_int_matrix - */ *m = calloc ( rows*columns, sizeof(int) ) /* allocate data array */Īssert(*m != NULL ) /* abort if allocation failed */ M = calloc ( rows, sizeof(int*) ) /* allocate pointer array */Īssert( m != NULL ) /* abort if allocation failed */ * Description: Allocate a dynamic int-matrix of size rows*columns return a pointer.Ĭalloc_int_matrix ( int rows, int columns ) ![]() Following is the content of the calloc_int_matrix.c pre-defined code snippets. calloc_int_matrix.c print_int_array.c.noindentįor 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. Makefile calloc_double_matrix.c main.c print_double_array.c.noindent Following are the default code snippets that comes with the plugin. The plugin comes with few pre-defined code snippets that you can insert into your code. Feature 8: Insert pre-defined code-snippet to the C code using \nr Feature 7: Save the file, compile it and execute it immediately. Feature 2: Adding C function using \ifįor writing a subroutine, type \if in normal mode, which will prompt for the function name (as shown in Fig1 below) and inserts the subroutine with default function content (as shown in Fig2 below).įig 6: Insert a Frame Comment Automatically Feature 6: To include header file, use \p”, and places the cursor in the < symbol in Insert mode where you can type the header file name. Note: To add custom fields to the header, modify the ~/.vim/c-support/templates/file-description.template file and add your own custom field. Now, when you create a new c file, it will show the modified values for AUTHOR and COMPANY as shown below. To change the default value of the AUTHOR and COMPANY, modify the default value in ~/.vim/c-support/templates/Templates $ vim ~/.vim/c-support/templates/Templates Fritz Mehner (mn), Company: FH Südwestfalen, Iserlohn This will also place the cursor in the Description field in Insert mode. ![]() c it opens the file with header as shown below. $ vim ~/.vimrcįiletype plugin on 8 Powerful Features of C.Vim Plugin Feature 1: Add Automatic Header to *.c file $ unzip /usr/src/cvim.zip Step 3: Enable the plugin in the ~/.vimrcĪdd the following line to the ~/.vimrc to enable the plugin for Vim editor. $ wget Step 2: Install the C Vim Plugin $ mkdir ~/.vim 3 Steps to Install the C.Vim Plugin Step 1: Download C Vim Pluginĭownload the plugin from vim.org website. This article explains how to install the plugin in 3 easy steps and 7 powerful features of the plugin.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |