Pauli's software ->Vedit resources -> File Open macros 26. 10. 2014  
----------

File Open macros

----------

This package contains four macros designed to make it easier to open files, switch buffers and run macros using keyboard.
The package contains the following macros:

Other files:

The macros all have uniform user interface. A window is opened at the left part of screen to list filenames. (Each macro uses different colors to make it easier to distinguish them.) Use cursor keys to select a file, then press Enter to open / switch to it. Function keys F4-F12 can be used to change display options or perform other actions, depending on the macro.

Search function

What makes these macros especially powerful is the search function. Just start typing characters for the search string, and the file list is narrowed to list only those files that contain the search string (anywhere in filename or in full path, depending on which one is displayed). You can then use up/down keys to choose a file in this shorter list, or type more characters until you have only one file in the list. Then press Enter to open file / switch to buffer. This makes it easy to find correct file if you have many files to choose from, even if you do not remember the exact filename. Backspace resets the search string and all the files are displayed again.
Most of the pattern matching codes and/or simple wildcards * and ? can be used in the search string (the wildcards are automatically converted into pattern matching codes). If you want to search for files that begin with specific characters, enter a space as first character of search sting. Similarly, a space at the end of strings matches the end of filename (unless the filename itself contains spaces).

See below for more details about each macro. To install these macros, unzip the package into your user-mac directory. Then define keyboard shortcuts to call the macros.

Download Download fileopen_131.zip   -   V1.3   -   26.10.2014   -   18 K   -   Vedit 6.15 / 6.20

--------

Switch Buffer

Buf_Switch.vdm is a buffer switch macro designed to be used with keyboard. It is particularly useful when you have a large number of files open.

Buf_Switch.vdm opens a window at the bottom left corner of the screen to list currently open buffers and corresponding filenames. Initially, the current buffer is highlighted.

Initially, the list displays buffer number and filename in buffer order.

When full path is displayed, F5 sorts by the path instead of just filename.

You can use the search function to find the required file (see above). You can enter numbers in the search string, too. This allows you to select a buffer by its number, as in Vedits original buffer switch function.

Tip: Configure F4 key to call this macro instead of the built-in buffer switch function. For details, see Keyboard shortcuts below.

Pressing F4 again exits the macro (same as Esc).


--------

Open recently used file

Open_Recent.vdm is used to open one of the recently used files or favorite files. It opens a window at the top left part of the screen to list the files.

Initially, the list shows recently used files as filenames only in MRU (Most Recently Used) order, the most recently used file on top.

When full path is displayed, F5 sorts by the path instead of filename. When Favorite files list is displayed, F5 does not toggle to MRU order (obviously), but it sorts either by filename or by full path, depending on which one is currently displayed. The search functionality can be used to find the required file (see above).

Note: The list is read from vedit.ini and it shows the state at the time when Vedit was last closed.

Tip: You may want to increase the maximum number of files in Recently Used Files list. Edit the setting MaxRecent in vedit.ini.


--------

Open file

Open_File.vdm is used to open a file from disk. It opens a window at the left part of the screen to list the filenames. Initially, it lists the current files directory. Directories are displayed in green color, files are displayed in yellow color. To switch to a sub-directory, select a directory name and press Enter. To switch to parent directory, select .. and press Enter.

Initially, the list shows filenames only in alphabetic order.

To avoid clutter in the file list, Vedit temporary files (those that have names such as "example.txt.1452.#02") are not displayed in the list. You can filter out other files such as .bak and .tmp by adding exclude filters. Press F11, then enter filters, separated by commas. On Vedit 6.2 or later, the filter settings are stored in user-mac.ini and remain in effect next time you run the macro.

The search functionality can be used to find the required file (see above). When file details are displayed, you can search files by size, date etc, in addition to filename. Number of files that match the search pattern is displayed at the left part of status line. If you enter a filename that does not exist in the list, an alert sound is given, the filename list is empty (except for the name of current directory) and status line turns red. If you press Enter at this point, you are offered an option to create a new file with given name. A dialog box opens where you can edit the filename if required, then click OK to create a file.

If you enter a directory name (with '\' as last character) in the search string, the status line turns green. You can now press Enter to switch to that directory. To switch to another drive, enter drive letter in the search string followed by a colon, for example "D:", then press Enter. This moves you to the root of that drive. If required, you can enter a path after the drive letter, for example "d:\projects\foo\". Tip: you can copy a directory path from any document and paste it into search string with Ctrl-V to directly switch to that directory (add the trailing \ if necessary).

Computer screen allows you to select drive interactively. To open it, navigate to the root of current drive (by selecting "..") and then select "[Computer]". You can also go to Computer screen directly from any directory by pressing F12. The Computer screen displays list of drive letters (C: to Z:) that are available in your computer. (Floppy drives A: and B: are not displayed. CD/DVD drives are displayed only if you have a disk inserted.) In addition, Computer screen lists some of the Vedit special directories: "CUR_DIR" (current dir before starting the macro), "HOME", "USER_HOME", "MACRO_DIR", "USER_MACRO" and "VEDIT_TEMP". If you have a project open, "CURRENT_PROJ_DIR" is displayed (if set). This gives easy access to these special directories. In addition, "My Documents" option is available, since this is the place where many programs store the files by default.

*) Requires new version of opencurs.vdm with support for option #103==6.

--------

Run a macro

Run_macro.vdm is used to load and execute a macro. It opens a window at the left part of the screen to list macro files (.vdm and .snp).

Initially, the macros in user-mac directory are listed. You can toggle between user-mac and macro directories with F8 key. To navigate to other directories, select a directory name (which begin with .\) or parent directory (..) and press Enter. To switch to another drive, enter drive letter in the search string followed by a colon, for example "D:", then press Enter. Or use the [Computer] screen, as in Open_File.vdm. The new directory is remembered when you toggle directories with F8.

When you press F4, labels in the selected macro are listed. You can now choose a label to be used as entry point. Press Enter to run the macro at that label (you need to know which labels in the macro code are valid entry points). Or press Esc to return back to file list. You can use Search functionality in the label list, but pressing Backspace returns you back to macro list.

================

Keyboard shortcuts

In order to take full advantage of these macros, configure hot-keys to call the macros. Since many of these macros perform same functions as built-in functions, you can replace the default key configuration to call these macros instead. For example, the key F4 normally executes {File / Buffer switch / Switch}. The macro Buf_Switch.vdm performs the same functions and more, so you can configure F4 to to call the macro instead. You can still use the built-in function through the menu system.

Here is an example keyboard configuration. Edit your vedit.key and replace the old configuration for these keys with the following:

F4              [VISUAL EXIT]#119=Reg_Free CallF(#119,"buf_switch.vdm") Reg_Empty(#119)
Ctrl-Shft-O     [VISUAL EXIT]#119=Reg_Free CallF(#119,"open_recent.vdm") Reg_Empty(#119)
Ctrl-Shft-Q     [MENU]FMQ
Alt-O           [VISUAL EXIT]#119=Reg_Free CallF(#119,"open_file.vdm") Reg_Empty(#119)
Ctrl-M          [VISUAL EXIT]#119=Reg_Free CallF(#119,"run_macro.vdm") Reg_Empty(#119)

(In the above configuration, the call for Quick Open has been changed from Ctrl-Shift-O to Ctrl-Shift-Q.)

================