Pauli's software ->Vedit resources -> Misc macros 31. 01. 2015  
----------

Miscellaneous macros

This section contains miscellaneous macros and other resources for Vedit text editor. Each macro is downloadable as a separate .zip package.

----------

Contents:

Menus
  User2.mnu - General purpose User Menu
Macros
  Preset.vdm - Configuration preset buttons
  Markers.vdm - Visual list of bookmarks
  T_reg.vdm - Visual list of text registers
  Cascade.vdm - Improved window cascade
  Write enable - Toggle write-enable status of current file
  chk_paren.vdm - Check that all parentheses have matching pair
  GotoFile.vdm - Open file selected from a list (Wildfile results, compiler output etc.)
  Search116.vdm - Macro to be called from double-click event macro
  Snippets.vdm - Code snippets insert/execute by double-clicking on a list window
  Highlight.vdm - Instant Syntax Highlighting
  Swap_Buffers.vdm  - Swap two buffers / tabs
Syntax files
  Mail.syn - Syntax highlighting for mail messages
  URL.syn - Syntax highlighting for URSs in a text file

--- User menu Bookmarks Text registers config Presets Cascade windows Write enable Go to file Check Spelling Check parentheses

USER2 Menu

USER2.MNU is replacement for the standard USER.MNU that cames with Vedit. This menu is indented for editing text files etc.
(For editing C files, see C_USER.MNU in C-tools section of my web page).

This menu contains most of the functions of the standard USER.MNU (excluding those related to C programming). In addition, there are items for calling the macros in this section.

Click on the menu to jump to the description of that item.  →

The menu item "Filename to clipboard" is in-line function in the menu. It copies the name of current file to clipboard. (Other items in the menu that do not have link are standard Vedit functions.)

Download: user2_mnu.zip   -   V1.1   -   Vedit 6.0   -   1.1k
---
Macros
---

Configuration presets

Preset.vdm macro dialog box

Preset.vdm macro displays dialog box that allows you to select one of up to 10 preset configuration settings by click of a button. You may have different settings for different programming languages, html, text files etc. (To cancel the macro, press Esc.)

Preset.vdm loads User and/or Tools menu, loads or modifies keyboard configuration, sets word separator and any other settings you choose to insert in the macro, and sets a default directory (cur_dir). You can use this macro to quickly set up configuration for specific file type before saving a new project. When you open the project next time, the settings, menus etc. will be automatically loaded.

If you have a file of corresponding type open, the macro may load syntax file and template editing file and set indent macro1) and double-click macro1) for that file type. You can then save file-open configuration so that these settings will be automatically available for any file of that type in the future.

You should edit the macro file to suit your needs and your directory structure. Some of the configuration buttons are commented out by default. You may comment/un-comment the buttons, but make sure the button index numbers will be correct. You can define max 6 buttons on Vedit 5.*, and max 10 buttons on Vedit 6.*.

1) Requires Vedit 6.21 or later.

Download: preset_13.zip   -   V1.3   -   31.01.2015   -   Vedit 6.00 / 6.21   -   3.0k     ( New version )

---

Bookmarks

Markers.vdm opens window that displays list of the bookmarks on current file. Displays bookmark number, line number where the bookmark points at, and sample text starting from the bookmark location. Using this list, you can go to the selected bookmark location, add and delete bookmarks.

While in the bookmark window, the following keyboard commands are available:
Up/Down - select a bookmark
Left/Right   - peek to bookmark location in the file
Enter - go to the bookmark location and exit macro
0 to 9- select the bookmark, go to the location and exit macro
Ins - store the current cursor location at selected bookmark
Del - delete selected bookmark
Esc - cancel macro and to return to the original location

Download: Markers.zip   -   V2.3   -   23.09.2010   -   Vedit 5.00   -   1.8k

---

Text registers

t_reg.vdm opens window that displays text registers 0-99 and the clipboard. After the register number, the contents of text register is displayed so you can easily identify the registers.

Use cursor keys to select the register and press enter to paste the contents at current cursor location. Or use keys 0 to 9 to paste any "user" register directly. In addition, you can copy data into a text register, or empty a text register.

While in the Text Registers window, the following keyboard commands are available:
Up/Down - select a register
Enter - paste register contents at cursor location and exit macro
0 to 9- paste register 0-9 and exit macro
c - paste clipboard contents at cursor location and exit macro
Numpad-*   - paste register 0 at cursor location and exit macro
Ins - copy highlighted block (or cursor line if block not highlighted) into selected text register
Del - empty selected text register
Esc - exit macro

In C.KEY and HTML2.KEY keyboard configurations, Numpad-* key executes this macro. You can then use the same keyboard commands as before to insert text register contents, but in addition, you are able to see the register contents before inserting, and you have the options to insert or delete text registers.

Download: t_reg.zip   -   V1.3   -   15.01.2009   -   Vedit 5.00   -   2.9k

---

Cascade windows

Cascade.vdm performs operation similar to Window -> Cascade. However, the standard cascade function does not use the full height of the screen, and the windows are close to each other and often unnecessarily wide.

Cascade.vdm adjusts window height as large as possible with the current number of windows. The windows are positioned so that the full width of Vedit application window is used. The windows are ordered at the order of buffer numbers. The currently active window will be the rightmost window.

The new version 1.1 for Vedit 6.0 takes the File Selector panel into account, but this is not quite accurate. Therefore, cascade works best when File Selector is not displayed. If you have Vedit 5.*, you should use V1.0 instead.

Download: Cascade.zip   -   V1.0   -   Vedit 5.20   -   0.5k
Download: Cascade.zip   -   V1.1   -   Vedit 6.00   -   0.5k

---

Write enable

Write_enable.vdm toggles write-enable status of the current file and optionally changes the write enable attribute. Now you do not need to manually close the file, change the file attributes with Windows Explorer and then re-open the file. The macro automatically closes and re-opens the file. The cursor position and bookmarks are saved and restored.

A dialog box opens for confirmation. If the file is currently read-only, the reason for that is displayed (file attribute, locked, opened in browse mode etc.). If the file is read/write, you have an option either just change to browse mode or to change the file attribute, too.

Download: write_enable.vdm   -   V1.0   -   11.02.2009   -   Vedit 6.0   -   2.4k

---

Check parentheses

chk_paren.vdm checks that all parentheses ()[]{} have a matching pair. In addition, checks quotes ("). Parentheses inside strings are ignored. If an error is found, cursor is moved to the error location. You can then correct the error, or continue the check from current cursor location.

(Note: for checking parentheses in C source files, see c_paren.vdm.

Download: chk_paren.vdm   -   V1.2   -   2.4.2004   -   Vedit 5.00   -   0.9k

---

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.

In search.tmp file, move cursor to the desired line and call this macro. 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 in PC-Lint output file (assuming the filename is _LINT.TMP) and with diff (or cvs diff) output file (*.dif). For these files, GotoFile.vdm calls macros Lint_Go.vdm or dif_gto.vdm (included in the zip).

If you call this macro in any other file, utags.vdm is called. Therefore you can replace the utags.vdm call in the user menu (Lookup in Ctags) with this macro. Configure a shortcut key (e.g. Ctrl-F12) to this menu function for easy access.

Download: GotoFile.zip   -   V1.3   -   15.02.2010   -   Vedit 6.10   -   2.6k

---

Double-click event macro

Search116.vdm - Call this macro from Double Click Event Macro to implements functionality similar to GotoFile.vdm (above) with mouse double-click, and to enhance the normal operation of double-click. When you double-click on the search results of Wildfile, or Lint output or diff output, the referred file is opened at the location given in the listing. If you double-click on some other file, a word is highlighted, as usually. However, search116.vdm gives several enhanced options:

The macro Load116.vdm, included in the zip file, sets up a double-click event macro that calls search116.vdm. Run this macro before saving your project, and the double-click event will be active when you open the project next time. Alternatively, you can copy the contents of this macro in your ustartup.vdm file so that the enhanced double-click functionality will be activated whenever you start Vedit.

Download: search116.zip   -   V2.6   -   09.05.2010   -   Vedit 6.10   -   2.4k

---

Code Snippets

Click for full size screenshot

Snippets.vdm implements code snippets in Vedit.

When you call snippets.vdm, a window opens at the right edge of screen to show the list of the snippets. To execute a snippet, either double-click on the name of a snippet, or use cursor keys to select a snippet and then press Numpad-Enter. The window is then closed and the snippet is executed.

The snippet file is basically a macro file but with extension .snp. Each snippet is a macro language routine that begins with a label and ends with return. The snippet can simply insert some text in the document, or it can execute any macro functions, or call an external macro file such as Wildfile, spelling checker, or UTF converter. It is even possible to call snippets.vdm to switch to another .snp file.

Snippets can be crouped by adding headings in the snippets list. This is done by inserting a special comment that begins as "//[" in the snippets file. The snippets file can contain local subroutines that are not displayed in the list. A label is only displayed if it is at the beginning of line, has both colons and starts with capital letter.

To make using snippets easier, you can add the call in your User or Tools menu and then configure a keyboard shortcut to the menu item. You can choose which snippets file is displayed by setting the filename in T-reg 40 and then calling label FILE_SET as follows:

  RS(40, "|(USER_MACRO)\html.snp") Call_File(100,"snippets.vdm", "FILE_SET")

By default (when the macro is called without label), the snippet file default.snp is used. There are two example snippet files included in the zip package: default.snp and html.snp. The screenshot shows snippets file default.snp currently activated, while html.snp is the file being edited.

Download: snippets.zip   -   V1.2   -   07. 09. 2010   -   Vedit: 6.1   -   6.0K

---

Instant Syntax Highlighting

Highlight.vdm offers a quick and simple way to highlight words in a file using syntax highlighting. You can use it with text files that normally do not use syntax highlighting, or you can add new keywords to an existing syntax file.

To highlight a word, mark the word as block (e.g. by double-clicking) and then call the macro. By default, the word is added to keyword group 4. You can add the word to keyword group 1, 2 or 3 by calling label H1, H2 or H3, respectively. An easy way to do this is by using snippets. File highlight.snp is included in the zip package. You can use it as it is, or you can copy it to your default snippets file.

If you call the macro while editing a file that does not have syntax file active, file tmp.syn is used as syntax file. If tmp.syn exist previously, the new keyword is added to it. To remove any old keywords from tmp.syn, call the label Clear_all.

If you call the macro when a syntax file is already active, the contents of the active syntax file is copied into tmp_*.syn and the keyword is added to that (the original syntax file is not changed). For example, if the active syntax file is c.syn, the new syntax file will be tmp_c.syn. If you later call the label Clear_all, the contents of the original syntax file is copied to tmp_*.syn again, removing all the keywords you have added. If you want to add your new keywords to the original syntax file permanently, either copy or rename the file.

If you call the macro when a file tmp_*.syn is active, the new keyword is added to that file.

Download: highlight.zip   -   V1.0   -   23. 05. 2010   -   Vedit: 6.1   -   1.6K

---

Swap Buffers / Tabs

The tabs in VEDIT are sorted by buffer number. The order of the files in the tabs depends on the order they are opened. This may not be very logical order in many cases. For example, you might want to put related files (e.g. foo.c and foo.h) next to each other.

Swap_Buffers.vdm allows you to re-order the tabs. It swaps the files between two buffers / tabs.

To use this macro, do the following:

  1. Switch to first buffer you want to swap.
  2. Switch to the second buffer you want to swap.
  3. Run the macro Swap_Buffers.vdm

The macro closes the current buffer and the previously accessed buffer, and then re-opens them in opposite order. Cursor position, bookmarks and window positions are saved and restored. Effectively, the files will be visible in the same window positions, but the buffer numbers and tabs have been swapped

Download: swap_buffers.vdm   -   V1.0   -   03. 01. 2011   -   Vedit: 6.1   -   1.6K

---
Syntax files
---

mail.syn

Syntax highlight file for saved mail files. Different colors for normal text, quoted text and header keywords.

Download: mail.syn   -   V1.0   -   13. 10. 2000   -   Vedit: (any?)   -   0.9K

---

URL.syn

A simple syntax file for highlighting URL's (web addresses) in a text file. Highlights URL's with protocol http, https, ftp or mailto.

Download: URL.syn   -   V1.1   -   21. 12. 2009   -   Vedit: (any?)   -   0.9K

---

( More syntax files can be found from the Other Programming Resources page. )