Skip to content

Text Editors

Linux provides text editors ranging from beginner-friendly to extremely powerful:

Text editors overview

EditorTypeBest for
nanoTerminalQuick edits, beginners
geditGUIDesktop users who want Notepad-like simplicity
vim / viTerminalFull-featured editing, ubiquitous on servers
emacsTerminal + GUIProgrammers, extensible to an IDE

nano is the easiest entry point to terminal editing. It shows a shortcut bar at the bottom of the screen - no modes to remember.

Terminal window
nano filename # open (or create) a file

Essential shortcuts:

ShortcutAction
CTRL-GDisplay help
CTRL-OWrite (save) the file
CTRL-XExit (prompts to save if unsaved changes)
CTRL-RInsert contents from another file
CTRL-KCut line
CTRL-UPaste
CTRL-WSearch
CTRL-CShow cursor position (line:column)

gedit is the GNOME text editor - similar to Notepad on Windows. It requires a graphical desktop environment and cannot run in a headless terminal session.

Terminal window
gedit filename # open file; creates it if it doesn't exist

Good for quick edits when you’re on a desktop. Not available over SSH unless X forwarding is configured.


vim (Vi IMproved) is the enhanced version of the classic vi. It’s installed on virtually every Linux/Unix system - if you only learn one terminal editor, make it vim.

vi uses modes - the same key does different things depending on the current mode:

ModeHow to enterPurpose
CommandDefault (press Esc)Navigate, delete, copy, issue commands
InsertPress iType and edit text (-- INSERT -- shown at bottom)
LinePress :File commands (save, quit, substitute)
CommandUsage
vi myfileOpen myfile
vi -r myfileOpen in recovery mode after a crash
:r file2Insert file2 at current position
:wWrite (save) the current file
:w myfileWrite to myfile
:w! file2Force overwrite file2
:x or :wqSave and quit
:qQuit (fails if unsaved changes)
:q!Force quit without saving
KeyMovement
Arrow keys / hjklLeft, down, up, right
0Beginning of line
$End of line
wNext word
bPrevious word
gg or :0Beginning of file
G or :$End of file
:n or nGGo to line n
CTRL-F / Page DownForward one page
CTRL-B / Page UpBack one page
^lRefresh and center screen
CommandAction
/patternSearch forward
?patternSearch backward
nNext match
NPrevious match
CommandAction
ddCut (delete) current line
yyCopy (yank) current line
pPaste after cursor
uUndo
CTRL-RRedo
xDelete character under cursor
dwDelete word

You can run shell commands without leaving vi:

:!wc % " Run wc on the current file (% = current filename)
:!ls /tmp " Run ls /tmp and show output
:sh " Open a subshell (exit to return to vi)

emacs is a powerful editor that can be extended with Lisp into a development environment. It uses CTRL and Meta (Alt or Esc) key combinations instead of modes.

Terminal window
emacs myfile # open in terminal
emacs & # open GUI version in background
KeyAction
emacs myfileOpen a file
CTRL-x iInsert (another) file at cursor position
CTRL-x sSave all modified files
CTRL-x CTRL-sSave the current file
CTRL-x CTRL-wWrite to a new filename
CTRL-x CTRL-cExit (prompts to save unsaved files)
CTRL-/Undo
CTRL-gCancel current operation
CTRL-sSearch forward
CTRL-rSearch backward
META-xRun an emacs command by name

Featurenanovimemacs
Learning curveLowMediumHigh
Modal editingNoYesNo
Ubiquity on serversHighVery highMedium
Scripting / macrosBasicVimScriptElisp
Best workflowOne-off editsEverythingPower users