Editor Integration
Quick Edit
Press Ctrl+E to open the current file in your configured editor. When you save and close the editor, leaf automatically reloads the preview.
Editor Picker
Press Shift+E to switch editors on-the-fly. leaf detects installed editors and classifies them as terminal-based (vim, nano) or GUI-based (VS Code, Sublime).
CLI Override
You can set the editor directly from the command line:
leaf --editor vim README.md
leaf -e vim README.md
Configuration
Set your default editor in ~/.config/leaf/config.toml:
editor = "vim"
You can also use the $LEAF_EDITOR environment variable.
Config Path and Line Placeholders
Use {$path} and {$line} as placeholders when configuring a custom editor command:
editor = 'nano +{$line}'
editor = 'nvim +{$line} +"normal! zz"'
editor = 'code -g {$path}:{$line}'
{$path} is replaced with the current file path and {$line} with the line currently visible at the top of the preview.
Open at Visible Line
When you press Ctrl+E and {$line} is used in the editor command, leaf opens the editor at the line currently visible at the top of the preview, so you land where you were reading. Without {$line}, the editor opens at the top of the file.
Terminal / Editor Tab Title
Both the terminal tab and the spawned editor tab display the current filename in their title, making multi-file navigation easier.
Supported Editors
vim, nvim, nano, emacs, helix (detected by hx), micro, VS Code, Sublime Text, Zed, and more.