Pauli's software ->Vedit resources -> Python Tools | 31. 01. 2015 |
Collection of VEDIT macros and other resources for Python programming.
This package contains some Vedit macros and other useful resources for a Python programmer.
You can run the macros from a Python specific Tools menu (pyTools.mnu). A Template Editing macro (Python.vtm) implements smart indent while you type. In addition, the package contains keyboard definition (python.key) for Python.
For easy download, all the macros and other files are packed in the file pyTools_10.zip. Click the link below to download the package.
Download pyTools_10.zip - V1.0 - 2015-02-01 - 15 K - Vedit 6.2
Unzip the files from pyTools_10.zip into your user-mac directory.
You can use preset.vdm to configure VEDIT for Python programming:
pyTools.mnu is a Tools menu for Python programming. It replaces the standard Tools menu (or Compile menu).
From this menu, you can easily call the macros below and perform other functions useful for Python programming.
Tip: use the macro preset.vdm to load this menu and to name it "pyTools".
The items in the menu are:
*) These macros can be found at other parts of my site. Click the link to see description. |
![]() |
Python specific keys:
Ctrl-F8 | Tools → Smart indent |
F12 | Tools → Function show/select |
Ctrl-F12 | Tools → Lookup in Ctags |
Ctrl-Shft-F12 | Tools → Return from Ctags |
Ctrl-Shft-C | Tools → Context display |
Numpad 5 | Insert comment character, then move to next line |
Ctrl-Cursor-Up | Move to previous line that has same indent level or less (previous block) |
Ctrl-Cursor-Down | Move to next line that has same indent level or less (next block) |
Other special functions:
Ctrl-Tab | Switch to previous buffer (toggle) |
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 [ ] |
Numpad + | Search again / search block, forward |
Numpad - | Search again / search block, backward |
Numpad Enter | Go to end of line and insert newline |
Python.vtm is a template macro for Python. It implements smart indent while you type.
After you press Enter key, the template macro calls pyIndent.vdm to indent the next line depending on the contents of the previous line.
(Since the template editing event does not capture Enter key, the indenting is executed after you press next key. You can type a space to indent, or just start typing text.)
If you press the : key, the indent macro checks if the current line needs to be undented (e.g. for else or elif statement).
To enable automatic indenting, load the template macro python.vtm, then save file type specific configuration.
pyIndent.vdm implements simple Smart Indent functionality. You can indent a single line or a highlighted block.
Since in Python blocks are specified using indenting itself, it is not possible to automatically detect the blocks for indenting. Therefore only simple indenting rules are used.
Note: The pyTools menu items calls the macro that has been specified by INDENT_MACRO config_string. Thus, the same menu item can be used with many different file types that need different indenting macros. You must set the value for the sting with command
Config_String(INDENT_MACRO,"pyIndent.vdm")
This can be easiest done with preset.vdm macro (see installing above).
pyFunc.vdm is similar to cfunc.vdm. It lists functions and classes in an indented list.
You can use the same keys as on cfunc.vdm to select a function and go to the definition, etc. (F1 opens the help file of cfunc.vdm). In addition, you can use Ctrl-Up and Ctrl-Down keys to move to previous/next line with the same indenting level (previous/next block).
Press F11 to open setup dialog. There you can enable options to:
In addition, you can adjust function list window width and colors.
pyContext.vdm displays the context of current cursor location. A window opens to list class, function, loops, if blocks etc. inside which the cursor location is.
Press Esc to close the window. Or, use cursor Up and Down keys to select a line in the display, then press Enter to go to that location in the file.
item in pyTools menu creates a tags database for your Python files. Ctags.vdm does not directly support Python. However, you can create tags database of Python functions by selecting Symbol Recognition Pattern in the Language section. When the symbol recognition dialog opens, enter the following:
Search: | ^[ \t]*def[ \t]+([A-Za-z0-9_]+)\( |
Replace: | \1 |
and select Regular Expressions as the Search Mode setting. (Ctags.vdm remembers the settings, so next time you run ctags, these fields are already filled.)
runs ctags.vdm with previously entered settings without showing the dialog box. This is a quick way to update tags database after you have made changes in your files.
finds a function from tags database and instantly switches to function definition. It calls the macro utags.vdm. Just put cursor on a function call and press the hotkey (Ctrl-F12).
switches back to the file and location from where "Lookup in Ctags" was called. These calls/returns can be nested to unlimited depth. If the file was not open before calling "Lookup in Ctags", and the file has not been modified, "Return from Ctags" closes the file.
menu item is the same as Return from Ctags, except that the file is not closed even if it was not previously open and it was not modified.
For more details, click [ Help ] button in the Ctags.vdm dialog box.