PhpStorm 2016.3 Help

Using Emacs as an External Editor

On this page:

What this tutorial is about

This short tutorial aims to walk you step by step through defining Emacs as an external editor for PhpStorm.

Basics of Emacs are out of scope of this tutorial.

Prerequisites

Make sure that:

Configuring Emacs as an external tool

Open Settings/Preferences dialog. To do that, you can, for example, choose File | Settings (on Windows and *nix) or PhpStorm| Preferences (on Mac OS), or click /help/img/idea/2016.3/settings.png button on the main toolbar.

Then, under the Tools node, open the page External Tools. On this page, you have to specify your Emacs installation as an external editor for the current file. This is how it's done...

  1. First, in the External Tools page, click /help/img/idea/2016.3/new.png. The Create/Edit Tool dialog box opens.
  2. In this dialog, do the following:
    • Type the tool name (Emacs) and optional description (Open Emacs)
    • Specify the name of the group, under which Emacs will appear in the Tools menu. In this example, the group name is Editors. This step is optional - if you specify no group name, then Emacs will appear in the Tools menu as is.
    • Clear the check box Open console.
    • Specify Emacs binary file location. You can either type it manually, or click the ellipsis button and find the desired binary in your file system.
    • Since you want to open the current file in Emacs, pass the file path as a parameter to the program: in the Parameters field, type $FilePath$.
    • Finally, specify the working directory - in our example, this is $ProjectFileDir$
    • Click OK.
    /help/img/idea/2016.3/ps_emacs1.png
  3. Apply changes and close the Settings/Preferences dialog.

Opening current file in Emacs

When you now look at the Tools menu, you will see the new node Editors. Pointing to this node reveals the Emacs command:

/help/img/idea/2016.3/ps_emacs2.png

Open a file for editing. Next, on the Tools menu, choose Editors|Emacs - and see the current file in Emacs also:

/help/img/idea/2016.3/ps_emacs3.png

Assigning a keyboard shortcut

By the way, PhpStorm makes it possible to assign a keyboard shortcut to this action: click /help/img/idea/2016.3/settings.png to open Settings/Preferences dialog, open the Keymap page, find Emacs, and choose Add Keyboard Shortcut on the context menu:

/help/img/idea/2016.3/py_emacs4.png

Enter Keyboard Shortcut Dialog dialog box opens, where you have to specify, which shortcut you would like this action to be associated with. Let’s, for example, use Ctrl+Shift+Alt+E:

/help/img/idea/2016.3/py_emacs5.png

No conflicts are reported, so click OK, and see the new shortcut appearing in the list of actions and on the Tools | Editors | Emacs menu:

/help/img/idea/2016.3/py_emacs6.png

See Also

Last modified: 23 March 2017