Emacs is a long-lived, highly extensible text editor from the GNU project. Unlike Vim, it has no separate insert mode to enter: you open a file and type. Commands are given with modifier keys.
Installing and starting
Your system may not have Emacs yet. To install it:
sudo apt install emacs-nox # Debian, Ubuntu
sudo dnf install emacs-nox # Fedora and relativesStart it inside the terminal with:
emacs -nw notes.txt-nw means "no window system". It matters when a graphical build is installed and you want to stay in the terminal. With emacs-nox it runs there anyway.
Key notation
The documentation writes keys in a compact form:
C-xmeans holdCtrland pressx.M-xmeans hold Meta and pressx. Meta is usually theAltkey. You can also pressEsc, release it, then pressx.C-x C-smeansCtrl-xfollowed byCtrl-s.C-x bmeansCtrl-x, then a plainb.
Watch the difference between the last two. Keeping Ctrl held can run another command.
The screen
From top to bottom you will see:
- The text area, showing a buffer (the text held in memory).
- The mode line, with the buffer name, position and current mode.
- The echo area, where messages appear. When Emacs asks you something, this line is called the minibuffer.
In the mode line, ** near the left means the buffer has unsaved changes.
Commands by name
Every action in Emacs is a named command. Keys are shortcuts to them. Press M-x, type the name and press Enter:
M-x display-line-numbers-modeThis one shows line numbers (Emacs 26 and later). Tab completes partial names.
The escape hatch
If you pressed something by mistake, or a prompt is waiting at the bottom, press C-g. It cancels the current command. Learn this one first.
To leave Emacs, press C-x C-c. It asks about unsaved files before closing.
A built-in tutorial
Press C-h t to open the Emacs tutorial, a practice text you work through inside the editor. The full GNU Emacs manual is available online.
Some terminals or desktop environments grab certain key combinations for themselves. If a shortcut does nothing, check your terminal settings or use the Esc form of Meta.
Try it
- Start
emacs -nw hello.txt. - Type a sentence and watch the mode line change.
- Press
C-x, thenC-gto cancel. - Save with
C-x C-s. - Exit with
C-x C-c, then check withcat hello.txt.
Check your understanding
Emacs
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.