sensible-editor
Open a file in a user's preferred editor
TLDR
Open a file in the default editor
Open a file in the default editor, with the cursor at the end of the file
Open a file in the default editor, with the cursor at the beginning of line 10
Open 3 files in vertically split editor windows at the same time
SYNOPSIS
sensible-editor [OPTIONS] [FILE...]
PARAMETERS
[FILE...]
Specifies one or more file paths to be opened by the selected editor.
[OPTIONS]
These represent options that will be passed directly to the chosen underlying editor program (e.g., -R for read-only mode in vi). sensible-editor itself has very few direct options beyond file arguments and the -- separator.
--
Stops processing of options, treating subsequent arguments as filenames. Useful if a filename begins with a hyphen.
--help
Displays a help message and exits.
--version
Displays version information and exits.
DESCRIPTION
sensible-editor is a utility that attempts to launch the user's preferred text editor program. It's part of the sensible-utils package, designed to provide a consistent and "sensible" way to invoke common applications like editors, pagers, or web browsers, regardless of the specific desktop environment or distribution configuration.
The command determines which editor to launch by checking, in order: the VISUAL environment variable, then the EDITOR environment variable. If neither is set, it consults the system's update-alternatives configuration for editor. As a last resort, it falls back to a predefined list of common editors (e.g., nano, vi, emacs). All arguments passed to sensible-editor are then forwarded directly to the chosen editor, making it seamless to open files or perform other editor-specific actions. This ensures scripts and applications can reliably open an editor without hardcoding a specific one.
CAVEATS
The actual editor launched depends heavily on environment variables (VISUAL, EDITOR) and system-wide alternatives (update-alternatives). If these are not configured as expected, sensible-editor might launch a different editor than the user prefers.
The fallback list of editors is predefined; if none of them are installed or accessible, sensible-editor may fail to launch any editor.
Since sensible-editor passes all arguments directly, it does not validate or interpret options intended for the underlying editor, which could lead to errors if invalid options are provided.
EDITOR SELECTION LOGIC
sensible-editor determines the editor to use by checking the following, in order:
1. The value of the VISUAL environment variable.
2. The value of the EDITOR environment variable.
3. The program configured as the system-wide default for editor via update-alternatives (e.g., /usr/bin/editor).
4. A predefined list of common editors (e.g., nano, vi, emacs), using the first one found in the system's PATH.
HISTORY
sensible-editor is part of the sensible-utils package, which originated in Debian-based Linux distributions. Its development aimed to address the challenge of providing a consistent and user-friendly way to invoke common applications like text editors, web browsers, and pagers across diverse Unix-like environments. Before sensible-utils, applications often hardcoded editor paths (e.g., /usr/bin/vi) or relied solely on basic environment variables, leading to inconsistencies. sensible-editor leverages environment variables and the update-alternatives system to offer a more robust and customizable solution, making it easier for scripts and users to reliably open their preferred editor.
SEE ALSO
editor(1), sensible-pager(1), sensible-browser(1), update-alternatives(8), mailcap(5)