Module editor

Text editor launching functionality

This module is primarily for use by other Lua modules that wish to allow the user to edit a particular text file. The default is to guess at the shell command to open a text editor from environment variables. To override the guess, replace editor.cmd_string. This can be done manually, as follows:

local editor = require "editor"
editor.editor_cmd = "urxvt -e nvim {file} +{line}"

Before running the command, {file} will be replaced by the name of the file to be edited, and {line} will be replaced by the number of the line at which to begin editing. This module also supplies several builtin command strings, which can be used like this:

local editor = require "editor"
editor.editor_cmd = editor.builtin.urxvt


editor.edit (file, line, callback)

Edit a file in a terminal editor in a new window.

  • Can't yet handle files with special characters in their name.


  • file
    Type: string
    The path of the file to edit.
  • line
    Type: number
    The line number at which to begin editing.
  • callback
    Type: function
    A callback that fires when the process spawned by the editor command exits, of type process_exit_cb.



Type: table
Built in substitution strings. Includes
  • autodetect (attempts to extract a terminal and editor from environment variables, and otherwise falls back to xterm and vim)
  • xterm
  • urxvt
  • xdg_open


Type: string
The shell command used to open the editor. The default setting is to use editor.builtin.xdg_open.