← XeFM crftwr/xefm on GitHub · craftware

Text Editor Integration

XeFM can hand files straight to your text editor. Put the cursor on a file — or select several with Space — and press E: XeFM steps aside while the editor runs and comes back automatically when you save and quit. Any editor that takes filename arguments works.

Usage

  1. Move the cursor to the file you want to edit, or select multiple files.
  2. Press E. With a selection, every selected file is passed to the editor in one launch (vim a.txt b.txt), so you get one session over all of them.
  3. Edit, save, and exit the editor — XeFM redraws where you left off.

Editing is available for local files only. Directories (and the .. parent) can’t be edited, and a warning is shown if you try; in a mixed selection they are simply skipped. E is rebindable via the edit_file action in your config’s KEY_BINDINGS.

Which editor is used

When you press E, XeFM picks the editor like this:

  1. A matching edit entry in FILE_ASSOCIATIONS wins — so you can send, say, images to an image editor and .md files to a Markdown app. If an entry is set explicitly to None, that file type has no editor and XeFM won’t fall back. See File Associations.
  2. Otherwise the TEXT_EDITOR setting is used.

Set TEXT_EDITOR in ~/.xefm/config.py:

class Config:
    TEXT_EDITOR = 'nano'   # your preferred editor

The shipped default depends on how you run XeFM: vim in a terminal, and VS Code (code) in the desktop app. Common choices include vim, nano, emacs, code (VS Code), subl (Sublime Text), and gedit. In terminal mode, prefer a terminal editor (vim, nano, emacs) so it can take over the screen; in the desktop app, a GUI editor works well.

If the configured editor can’t be found or exits with an error, XeFM reports it and restores the file view.

See also