vi or vim. Bash determines which editor to launch by checking two environment variables:
| Variable | Purpose | Examples |
|---|---|---|
| VISUAL | Full-screen, visual editors | vim, emacs |
| EDITOR | Simple, line-oriented editors | nano, ed |
If both
VISUAL and EDITOR are set, many programs will prefer VISUAL. To ensure consistency, consider exporting both variables.1. Setting the Editor for the Current Session
To switch tonano for just the active shell session, export the EDITOR variable:
nano instead of vi.
This change only applies to the current session. Close the terminal or start a new shell, and you’ll revert to the previous default.
2. Making the Change Permanent
To havenano (or another editor) as your default every time you open a new shell, add the export line to your Bash startup file. Most users place it in ~/.bash_profile:
nano as the standard editor.
Links and References
Check your understanding with the quiz.