Use Emacs as an External Editor in PyCharm

What this tutorial is about This short tutorial aims to walk you step by step through defining Emacs as an external editor for PyCharm. Basics of Emacs are out of scope of this tutorial.

Prerequisites Make sure that: You are working with PyCharm 2.7 or later. This tutorial is created with PyCharm version 5.O.x.

Emacs is downloaded and properly installed on your computer.

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 PyCharm| Preferences (on macOS), or click 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... First, in the External Tools page, click . The Create/Edit Tool dialog opens. 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 checkbox 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. 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: Open a file for editing. Next, on the Tools menu, choose Editors|Emacs - and see the current file in Emacs also:

Assigning a keyboard shortcut By the way, PyCharm makes it possible to assign a keyboard shortcut to this action: click to open Settings/Preferences dialog, open the Keymap page, find Emacs, and choose Add Keyboard Shortcut from the context menu: Keyboard Shortcut dialog opens, where you have to specify, which shortcut you would like this action to be associated with. Let’s, for example, use Ctrl+Alt+Shift+E : 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:

Last modified: 19 August 2020