Emacs Basics

By Xah Lee. Date: . Last updated: .

Start Emacs as Graphical User Interface App

On a text terminal, type:

# linux
emacs
# Mac OS X. start emacs in text terminal
/Applications/Emacs.app/Contents/MacOS/Emacs
# On Windows, PowerShell.
~/Downloads/emacs-27.1-x86_64/bin/runemacs.exe

Start emacs and open a file:

# open a file with emacs
emacs fileName

Start Emacs in text terminal mode

On a text terminal, type:

# linux. start emacs in text terminal
emacs -nw

-nw is same as --no-window-system, means run emacs in text terminal.

# Mac OS X. start emacs in text terminal
/Applications/Emacs.app/Contents/MacOS/Emacs -nw
# On Windows, PowerShell. start emacs in text terminal
~/Downloads/emacs-27.1-x86_64/bin/runemacs.exe -nw

Use Graphical Menu

Emacs by default supports mouse and menu.

emacs menu 2021-07-19
Emacs menu.

The keyboard shortcuts are shown beside the menu.

So, use menu, and you can learn the keyboard shortcuts.

Most Important Emacs Keys

These keys gets you started.

To navigate cursor, just use the arrow keys.

use Ctrl with arrow to move cursor by words.

Undo

To undo, press Ctrl+_

Redo

To redo, press Ctrl+g then do a undo Ctrl+_. Further undo will all be redo. Press Ctrl+g to reverse direction again.

Save

To save file, press Ctrl+x Ctrl+s.

Quit Emacs

Press Ctrl+x Ctrl+c.

Quit without Saving

To quit without saving, just do quit and emacs will ask if you want to save.

If the keys you press seem to do weird things, then, press Ctrl+g. This will cancel the sequence of keys you may have pressed by mistake.

Congratulations! You are now a Emacs Master!

With the above, you can edit any text file. Now, you can learn how to do search, find/replace, and new shortcuts for efficient navigation. Goto Emacs Keys.

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc