Pauli's software ->Vedit resources -> C Tools 23. 08. 2020  

C-Tools

Collection of Vedit macros and other resources for C programming.

This package contains useful resources for a C programmer. From a special user menu, you can easily run the macros included. In addition, there is an enhanced template editing macro, and keyboard configuration file for C. See below for the descriptions of each file.
For easy download, all the macros and other files are packed in the file ctools25.zip. Click the link below to download the package.

Download Download ctools25.zip   -   V2.5   -   23.08.2020   -   24.0 K   -   Vedit 6.2

------

Vedit 6.2: This package has been tested with Vedit 6.24. Some of the macros are new versions of the macros that come with Vedit.

Old versions: Most of the functions should work with older Vedit versions, too. However, if you have an older version and you encounter some compatibility problems, you can donwload the old version of C-Tools here:

Download Download ctools10.zip   -   V1.0   -   14.05.2001   -   16.5 K   -   Vedit 5.1.

======

Descriptions of the files in CTOOLS24.ZIP:

======

Documentation

c_tools.txt - Description of the keyboard commands and menu functions, as well as documentation for the macro search_inc.vdm.

search_inc2.chm - Help file for search_inc2.vdm. Click Help button on any search_inc2 dialog to get context sensitive help for that dialog.

cfunc.chm - Help file for cfunc.vdm. Can be called by pressing F1 while the function list is displayed, or by double-clicking on the file name (cfunc.chm) on Windows Explorer.

------

User Menu for C

C_User.mnu is a user menu adjusted for C programming. Replaces the standard User menu. Use this menu as it is, or copy the lines of interest to your own User Menu.
From this menu, you can easily call the macros below and perform other functions useful for C programming. Tip: use the macro preset.vdm to load this menu and to name it "C-User".

  The items in the menu are:

*) These macros can be found at other parts of my site. Click the link to see description.
1)  Standard vedit function.
2)  Requires ctags.vdm v2.2 or later (Vedit 6.2).

C user menu

C_USER.MNU   -   V2.2   -   Vedit: 5.0

C Keyboard file

C.KEY is Keyboard definition for C programming. Based on Vedit NORMAL.KEY configuration, but adds some useful keyboard macros, and uses the C_user.mnu above. You can use this keyboard file as it is, or just copy those keyboard macros you want to and add them in your own keyboard file.

Some of the new features include:

Alt-' Quick C comment / comment out from cursor to EOL
Alt-1 Comment-out a line and move to next line
Alt-2 Un-comment a line and move to next line
Alt-3 Highlight C block {...{...}...}
Alt-4 Highlight text inside parentheses (...)
Alt-5 Comment-out block using #if 0
Ctrl-7 Insert pair of curly braces { }
Alt-7 Insert lines with curly braces
Ctrl-8 Insert pair of parenthesis ( )
Alt-8 Insert pair of square braces [ ]
Alt-; Go to end of line and insert a semicolon
Numpad 5 Quick C++ comment
Numpad + Search again / search block, forward
Numpad - Search again / search block, backward
Numpad Enter     Go to end of line and insert newline
Numpad * Visual text register insert (calls t_reg.vdm)
F11 Visual bookmarks (calls markers.vdm)
(see the menu) Hotkeys for calling C-user menu functions

C.KEY   -   V1.2   -   Vedit 6.1

-----
Template editing
-----

C Template Editing macro

C123.VTM is enhanced version of the C.VTM template macro that comes with Vedit. The template macro expands C keywords while you type, inserts parentheses and creates indent for flow control commands. This version has the following enhancements:

You can change the indenting style by selecting "C macro setup" in the C-User menu (this calls the macro C_setup.vdm).

Click here for full list of keywords expanded by the template macros.
Click here for template edit example on how keyword "for" is expanded.

(This macro replaces the three template macros C1.VTM, C2.VTM and C3.VTM in some earlier versions of my C-Tools package.)

C123.VTM   -   V2.4   -   25. 07. 2017   -   Vedit 6.02

Macros

Matching #if

c_ifs.vdm finds the matching pair for #if, #else or #endif. If the cursor is on a line that contains #if, the matching #else or #endif is searched. If the cursor is on a line that contains #else, the matching #endif is searched. If the cursor is on a line that contains #endif, the matching #if is searched. Handles nested #if blocks.

In addition, the macro finds next case branch in switch-case statements.

C_ifs can also used on makefile, to match ifeq,ifdef,ifndef.

C_IFS.VDM   -   V1.7   -   14. 05. 2013 -   Vedit 5.00

Show active #if's

Show_Ifs.vdm opens a window that displays all the #if lines that are effective at the current cursor position. This is an easy way to find out if the current line would be included in conditional compilation or not. Press any key to close the window.

SHOW_IFS.VDM   -   V1.4   -   17. 10. 2012   -   Vedit 6.00

Show context

C_context.vdm displays the context of current cursor location. The macro opens a window that displays all the switch, case, if, while etc. lines and the function definition within which the current cursor location is.

Press Space or Esc to close the window, or cursor up/down to select a line and then Enter to go to that line.

C_CONTEXT.VDM   -   V1.4   -   2016-01-19   -   Vedit 6.00 NEW

Check parentheses in C source

C_paren.vdm checks that all parentheses ()[]{} in C source file have a matching pair. (Works quite well on Vedit macros, too.) In addition, checks strings ("), C comments (/*...*/) and #if...#endif pairs. Parentheses inside strings or C or C++ comments are ignored. If an error is found, cursor is moved to the error location. You can then correct the error, or continue checking from current cursor location. This macro can be called from Wildfilew.vdm to check multiple files.

(Note: for checking parentheses in text files, see chk_paren.vdm) in Misc Macros section.

C_PAREN.VDM   -   V3.2   -   6. 11. 2007   -   Vedit 5.00

C function auto complete

C_autoc.vdm performs auto complete function for function calls or other identifiers in your C source file.

To use this macro, type a few characters from the beginning of the function name, then call this macro. If you typed enough characters to uniquely identify the function, the function name is competed, parenthesis are added, as well ass correct number of commas to separate the parameters.

If you have more than one function that matches with the characters you typed, the status line shows message such as "Match 1 of 4". You can then press Ctrl-TAB again for next match and so on. (Use Undo key to display previous match.)

This function uses the TAGS database created with the Ctags.vdm macro that comes with Vedit.

C_AUTOC.VDM   -   V1.3   -   30. 08. 2020   -   Vedit 5.20

C Function Select

cfunc.vdm is an enhanced version of the cfunc.vdm macro that comes with Vedit. The macro opens a window which displays a list of all the C functions in the file. You can use cursor keys to select a function, then press Enter to go to the location of the function definition in the file.

Some of the enhanced features:

šIf the file contains large number of functions, it may be difficult to locate the function you are searching. On cfunc.vdm, you can type search string on status line at any time. The functions that do not contain the search string will change color and the cursor moves to first matching line. You can then either type more characters to narrow the search, or move cursor down/up to pick any of the matching functions (non-matcing lines are skipped). Press Backspace to clear the search.

cfunc.VDM   -   V2.5   -   15. 12. 2010   -   Vedit 6.1

C Macro Setup

Selecting indent mode

C_setup.vdm allows you to configure the operation of some C-related macros, using dialog boxes. You can configure the following functions:

First, click a button to select which one of the above settings you want to setup. A new dialog box opens, depending on your selection.

The currently selected settings are read from the macro being configured and used as defaults in the dialog box. To store the indent mode settings, c_setup.vdm modifies the configuration options in macro code of C123.VTM and c_indent.vdm. For other settings, c_setup.vdm calls the setup routines of corresponging macro and the settings are stored in .ini file.

C_SETUP.VDM   -   V2.4   -   16.01.2021   -   Vedit 6.0 (Win)

---

Go to file

GotoFile.vdm opens another file based on the contents of current file. It can be used with Wildfile search results, Lint output and diff output, and for ctags lookup.

This macro is called when you select "Lookup in Ctags" on the C-User menu, or if you press Ctrl-F12. On the standard User menu which comes with Vedit, that menu option calls directly the macro utags.vdm. Using GotoFile.vdm allows this function to be expanded to some additional uses.

In Wildfile search results display (search.tmp), move cursor to a line that contains the search result you are interested in, and press Ctrl-F12. The searched file is opened and the cursor is moved to the specified line. This is a quick way to go to the location where searched string was found. The same method can be used with diff (or cvs/pvcs diff) output file (*.dif). In this case GotoFile.vdm calls dif_gto.vdm (below).

If you call this macro in any other file, utags.vdm is called.

GOTOFILE.VDM   -   V1.3   -   15. 02. 2010   -   Vedit 6.10

GotoFile support for diff output

dif_gto.vdm - Go to line referred in diff output or PVCS difference output file.
When the output of diff file compare utility (or PVCS difference) is viewed on the current buffer, you can move cursor to a line of interest and call this macro. The destination file is opened and the cursor is moved to location referenced on the line.

This function is called (via GotoFile.vdm) when you select option "Lookup in Ctags" on the User menu, and the current file has an extension .dif. On Vedit 6.20 or later, this macro can be called from double-click event by setting Vedit string value DBL_CLICK_MACRO.

DIF_GTO.VDM   -   V1.0   -   10. 11. 2003   -   Vedit 5.0

Open include file

Search_inc.vdm - Search and open include file pointed by cursor.
Put cursor on the line containing include statement and call this macro (Alt-F12). The include file is opened immediatelly.

The file is searched within include directories listed in a file include.lst. If the filename is enclosed in quotes " ", the file is first searched from the source file's directory. If the filename is enclosed in arrow braces < >, it is only searched from the directories listed in the include.lst.

If you list the directories in the same order as you do for your compiler, the macro uses same search order as your compiler would use. Thus, if you have multiple include files with same name, the correct one is automatically opened.

If a block is highlighted, it is used as filename even if it is not enclosed in quotes or arrow braces. If file is not found, a dialog opens allowing you to edit the filename or browse for the file.

For more detailed description of this macro, see the file c_tools.txt included in this package.

Note: This macro is obsolete since the same functionality is available in search_inc2.vdm below. However, it is still included here since it is simpler and thus may be used for starting point for your own macros.

SEARCH_INC.VDM   -   V1.3   -   05. 12. 2006   -   Vedit 6.1

Search in include files

Search_inc2 is an expanded and enhanced version of search_inc.vdm macro above. It implements several functions related to #include files, including the functionality of search_inc.vdm. The functions can be selected from a dialog box, but some of them can be executed directly for example from the c_user menu included with this C Tools package.

search_inc2 List Files dialog

The main functions are:

List files - This function lists all the files included from current file and recursively all files included from the included files.
You have options to:


Find file - Find and open specified include file.
You can enter the file name in the dialog box, and choose if you want to search for the file in current files directory, include path or both.
If the cursor is on a line that contains an #include statement, the filename is filled automatically, and the search locations are set depending on the filename delimiters <> or "", so normally you would only need to hit the Return key.
This function can be called executed by selecting 'Open include file' from the User menu. This calls the label OPEN_FILE in the macro. In this case, the dialog box is not displayed and the include file is instantly opened.


search_inc2 Find Definition dialog

Find Def - Find definition (#define, typedef or function prototype).
This operation performs a search among all the files included from the current file and recursively all the files included from the included files to find the definition of the symbol on which the cursor is located.
The search is performed by creating a search pattern depending on the type of symbol being searched, according to the C language syntax.

The Find Definition operation can be executed directly, without displaying the dialog box, by selecting 'Find Definition' from the c-user menu. This calls label "FIND_DEF".


Text search - Freeform text search within included files.
Its operation is similar to Wildfile, except that the search is performed within all the files included from current source file and recursively within all files included from the included files. The search is performed in the same order as your compiler would do.
The normal search options can be selected: Case sensitive, Word, Skip Comments, and search mode Simple / Pattern / Regular Expression / RegExpr Maximized.
The search results can be displayed in a list, the same way as in Wildfilew.vdm. You can then double-click on a line in the search results listing to open that file and show the location where the string was found. Alternatively, you can choose to open the first result immediately, without displaying the list.


SEARCH_INC2.VDM   -   V2.1   -   28. 10. 2010   -   Vedit 6.1    NEW