sensible-editor: Quick Guide to Open Files in Your Default Editor


sensible-editor quick guide

Open files in your default editor with sensible-editor. This small command is handy when you want to respect your system’s preferred editor and cursor positioning behaviors.

Quick-start examples

Try these in a terminal. Replace paths with real file paths on your system.

  • Open a file in the default editor:
sensible-editor /path/to/file
  • Open a file with the cursor at the end of the file:
sensible-editor + /path/to/file
  • Open a file with the cursor at the beginning of line 10:
sensible-editor +10 /path/to/file
  • Open 3 files in vertically split editor windows at the same time:
sensible-editor -O3 /path/to/file1 /path/to/file2 /path/to/file3

Note: If a file path contains spaces, quote it:

sensible-editor "/path/with spaces/file.txt"

What this command does

  • It launches the system’s default editor as defined by your environment (often via the EDITOR variable).
  • It supports simple paths and multiple files in one go.
  • The -O option (e.g., -O3) opens multiple files in vertically split windows, which is useful for cross-referencing.

Common pitfalls

  • Not having EDITORs configured: If sensible-editor opens a surprising editor, check your $EDITOR variable (e.g., echo $EDITOR). Set it to a preferred editor like vim, nano, or code:
export EDITOR=nvim
  • File paths with spaces: Remember to quote paths or escape spaces to avoid shell word-splitting issues.

  • Large number of files: Opening many files at once can overwhelm the editor UI. Prefer opening a small set or use separate sessions.

Practical tips

  • If you’re unsure which editor will open, test with a temp file:
sensible-editor /tmp/testfile.txt
  • Combine with editors’ features: after opening, you can search, jump to lines, or split panes depending on your editor, since sensible-editor respects the default editor’s behavior.

When to use sensible-editor

  • You want a quick, consistent way to open files in the editor you already use.
  • You need to open one or more files and optionally place the cursor at a specific location.
  • You prefer not to specify the editor every time on the command line.
  • tldr: If you haven’t updated your command cache in a while, consider running:
tldr --update
  • For more details about sensible-editor, see its man page or online documentation:
man sensible-editor

See Also