External Tools Plugin

The External Tools plugin allows you to execute external commands from gedit. You can pipe some content into a command and exploit its output (for example, sed), or launch a predefined command (for example, make).

Use the External Tools Manager to create and edit commands. To run an external command, choose it from the Tools menu.

10.4.1. Built-in Commands

The following commands are provided with the External Tools plugin:

Build

Runs make in the current document's directory.

Directory Listing

Lists the contents of the current document's directory in a new document.

Environment Variables

Displays the environment variables list in the bottom pane.

Grep

Searches for a term in all files in the current document directory, using pattern matching. Results are shown in the bottom pane.

Remove Trailing Spaces

Removes all spaces from the end of lines in the document.

10.4.2. Defining a Command

To add an external command, choose Tools ▸ External Tools.

In the External Tools Manager window, click New. You can speficy the following details for the new command:

Description

This description is shown in the statusbar when the menu command is chosen.

Accelerator

Enter a keyboard shortcut for the command.

Commands

The actual commands to be run. Several gedit environment variables can be used to pass content to these commands: see Section 10.4.4 ― Variables.

Input

The content to give to the commands (as stdin): the entire text of the current document, the current selection, line, or word.

Output

What to do with the output of the commands: display in the bottom pane, put in a new document, or place in the current document, at the end, at the cursor position, or replacing the selection or the entire document.

Applicability

Determines which sort of documents can be affected by the command, for example whether saved or not, and local or remote.

10.4.3. Editing and Removing Tools

To edit a tool, select it in the list and make changes to its properties.

To rename a tool, click it again in the list.

To restore a built-in tool that you have changed, press Revert.

To remove a tool, select it in the list and press Remove. You can not remove built-in tools, only those you have created yourself.

10.4.4. Variables

You can use the following variables in the Commands field of the command definition:

  • GEDIT_CURRENT_DOCUMENT_URI
  • GEDIT_CURRENT_DOCUMENT_NAME
  • GEDIT_CURRENT_DOCUMENT_SCHEME
  • GEDIT_CURRENT_DOCUMENT_PATH
  • GEDIT_CURRENT_DOCUMENT_DIR
  • GEDIT_DOCUMENTS_URI
  • GEDIT_DOCUMENTS_PATH