C/C++ Support Vim Plug-In | |||||||||
|
|
|
root menu |
C/C++ Support - Vim Plug-In( version 6.2 )View the ReadmeRead the C/C++ Support Help File The key mappings of this plugin (PDF) What's new? Customizable file skeletons Jul 2017 New Plug-in Versions Released Jul/Aug 2016 Plugin featured in the The Geek Stuff tutorial |
|
Features |
---|
Speed-up the development of C/C++ programs:
|
Menus | Explanation |
---|---|
Menu Comments : insert commentsA lot of the menu entries are defined in a so-called template library. The library defines the menu entries, maps and the inserted text. The personal information can also be configured there. A file header can be inserted into each new file:
/*
* =====================================================================================
*
* Filename: someprogram.c
*
* Description:
*
* Version: 1.0
* Created: 31.03.2016 10:36
* Revision: none
* Compiler: gcc
*
* Author: Wolfgang Mehner (WM), thisguy@doggymail.de
* Organization:
*
* =====================================================================================
*/
This prolog is generated from the template shown below. This template file can easily be changed by the user.
Tags (like == Comments.file description impl == map:cfdi, shortcut:c, start, noindent == /* * ===================================================================================== * * Filename: |FILENAME| * * Description: <CURSOR> * * Version: 1.0 * Created: |DATE| |TIME| * Revision: none * Compiler: gcc * * Author: |AUTHOR| (|AUTHORREF|), |EMAIL| * Organization: |ORGANIZATION| * * ===================================================================================== */ == ENDTEMPLATE == The entry keyword comments ➞ todo generates a special end-of-line comment. These comments are easily locatable by their keywords (e.g. :TODO:). Date and author reference name are inserted by the editor.
/* :TODO:29.02.2015 12:34:WM: */
These comments are not for the final version of a script, of course. |
|
Menu Statements : insert statementsInsert statements with jump tags for convenient editing, using the entry if block else or via the map \sife: if ( | ) { <-IF_PART-> } else { <-ELSE_PART-> } The cursor is positioned after the "if". Use CTRL+J to jump to the tags and start editing. A lot of menu entires have a special behavior in visual mode. Select some lines in visual mode ... x = sqrt ( y ); printf ( "%f\n", x ); then use the entry if block else. The text is inserted around the selected lines and they are indented: if ( ) { x = sqrt ( y ); } else { } printf ( "%f\n", x ); |
|
Menu Idioms : insert frequently used statementsInsert an empty function using function. You will be asks for the name of the function and the following lines will be inserted: /* * === FUNCTION ====================================================================== * Name: brain_function * Description: * ===================================================================================== */ void brain_function ( <+argument_list+> ) { return <+return_value+>; } /* ----- end of function brain_function ----- */ The menu also offers code snippets for important library functions, such as malloc. After prompting for the name of the pointer, the call is inserted with an error check: p_data = malloc ( sizeof(<+TYPE+>) ); if ( p_data==NULL ) { fprintf ( stderr, "\ndynamic memory allocation failed\n" ); exit (EXIT_FAILURE); } free ( p_data ); p_data = NULL; Here the template library comes in particularly handy. While we try to provide a sensible standard implementation, which is very useful for quickly written, small programs, you might want to adapt the inserted code to your personal needs. |
|
Menu Snippets : insert code snippets and manage templatesPick up function prototypes from one or more lines. Insert the prototypes elsewhere. Mark the following lines and choose pick up func. prototype: double f3_sub1 ( // comment comment comment /* */ double r1, /**/ // the first /* ssssss */ double r2 ) // the second Now mark these lines and choose pick up func. prototype again: int f4_sub1 ( int n1, /* multi line comment */ int n2, int n3 /* comment3 */ ) The following lines will be inserted by insert prototype(s): double f3_sub1 ( double r1, double r2 ); int f4_sub1 ( int n1, int n2, int n3 ); (See :help csupport-proto) The plug-in comes with a facility to extract, manage and insert often used code snippets. Visually select a few lines and use the menu entry write code snippet to write these lines into a file. The code snippet can then be edited and inserted again using read code snippet. (See :help csupport-snippets) The templates which define the behavior of most of the menu entries are also manage here. Use templates setup wizard to create a personalization file with your personal details for the comments. The templates support different coding styles. Use the entry choose style to switch between them. (See :help csupport-templates) |
|
Menu Run : compile and run the program, start debugger, ...Run the program. In case of errors an error window will be opened to show the current list of errors: Redirect the output into a Vim buffer: Run current buffer through the source code analyser splint and open an error window: Run current buffer through the source code analyser CodeCheck (Trademark of Abraxas Software, Inc.) and open an error window: |
|
Menu Help : call helpHelp is quickly accessible through the Help menu. Place the cursor on the name of a function ...
strcpy ( p1, p2 );
then use the entry or the map \hm and the manpage will be displayed in a Vim buffer. The same works for any word in the English language. Placing the cursor on a word and hitting \he opens a dictionary for the word. |
|
Toolbox Make : make integrationRun make in the current directory, passing cmd.-line arguments: :Make -j3 In larger projects a specific makefile can be chosen: :MakeFile ../Makefile... and run from anywhere: :Make docThe tool will change the directory and execute the previously chosen makefile, independently of the current working directory. Similar tools exist for CMake and Doxygen, for their setup see the Readme or :help csupport-toolbox . |
Page updated: October 23 2018 / Mail to: Wolfgang Mehner