External Editors Preferences

If you'd rather use one or more external applications rather than PowerGREP's built-in file editor to view or edit files, you can configure them in the External Editors section in the Preferences screen. The editors will appear in the Edit File menu in the File Selector, and in the Edit File menu in the Results panel.

External Editors Preferences

To add an editor, click on the New button. Type in the label that should appear on the editor's menu item in the Label field.

In the command line field, type in the complete command that PowerGREP should execute to launch the editor and open the current file in the editor. You can use all of the path placeholders that are also available in PowerGREP's search and replace and "collect data" operations. Most of the time, you will use "%FILE%". %FILE% is replaced with the full path to the file being viewed in the file viewer. The double quotes make sure that filenames with spaces in them are kept together.

Some editors can open a file at a specific position if you supply the correct parameter. You can use two placeholders on the command line to pass the location of a search match on the command line. %START% is replaced by an integer indicating the byte position of the start of the search match, counting all bytes before the match starting from the beginning of the file. The first character in the file has byte position 0 (zero). The second character has position 1 in single byte character set text files, byte position 2 in UTF-16 files, byte position 4 in UTF-32 files, etc. %STOP% is replaced by the byte position at the end of the match, counting all bytes before the match, and all byte in the match. The length of the match equals %STOP%-%START%.

Since many editors support command line parameters for placing the cursor at a specific line or column, but not at a specific byte offset, PowerGREP also provides %LINE% and %COL% placeholders to indicate the start of the match, and %LINESTOP% and %COLSTOP% to indicate the first character after the match. The first character in the file is on line 1 and column 1. The second character is on column 2, regardless of the file's encoding. The line and column placeholders only work when the search results were produced by an action with the context type set to "use lines as context" and "show line numbers" turned on. When collecting context in a different way, or not at all, PowerGREP does not scan the file for line breaks to calculate line numbers.

The working folder is the folder that is made the current one when the editor is launched. Typically, you will enter %PATH% here, which is the full path to the file being shown in the file viewer, without the file name. You should not put double quotes around the working folder, whether it is likely to contain spaces or not.

You can restrict the editor to be available for certain file types only. This restriction is based on file extensions. For an HTML editor, you could enter *.htm;*.html;*.shtml separating the extensions with semicolons. If you leave the list of extensions blank, then the editor will be available for all files.

If you turn on the "default editor" checkbox, then PowerGREP will use this editor instead of its built-in editor when you click the Edit button on the toolbar in the Results panel, or when you double-click on a file in the results. You can set more than one editor as being a default editor. If you do so, PowerGREP first checks if there is a default editor with the file's extension listed as an extension the editor recognizes. If there is more than one such editor, the topmost one in the list is used. If no default editor has the extension listed, PowerGREP invokes the topmost editor you marked as default and configured to handle all files (i.e. by not listing any file extensions).

Open Files with This Editor

Turn on to allow this editor to appear in the Edit submenu for files matched by the file mask for this editor; or all files if you don't specify a file mask.

If you turn off this option, the editor will not be available for any files.

You can use the %FILE% placeholder to represent the file on the command line.

Open Archives with This Editor

Turn on to allow this editor to appear in the Edit submenu for archives matched by the file mask for this editor; or all archives if you don't specify a file mask.

If you turn off this option, the editor will not be available for any archives.

You can use the %FILE% placeholder to represent the archive on the command line.

Which files are treated as archives depends on the archive configuration selected in the File Selector.

Open Folders with This Editor

Turn on to allow this editor to appear in the Edit submenu for folders matched by the file mask for this editor; or all folders if you don't specify a file mask.

If you turn off this option, the editor will not be available for any folders.

You can use the %PATH% placeholder to represent the folder on the command line.

Open All Files Command for This Editor

If all the files in the results have extensions supported by this editor, or if you did not list any extensions for this editor, show an Open All Files command that opens all the files in the results in this editor.

PowerGREP will launch one instance of this editor for each file in the results. You should only enable this command for applications that are capable of reusing existing instances. If there are 10 files in the results, PowerGREP will launch 10 instances. The application should be capable of signaling itself so that 1 instance opens all 10 files, instead of 10 instances cluttering your desktop. To make sure your system doesn't crash with thousands of instances of your editor, PowerGREP won't launch more than 10 instances if the application doesn't close them down.