X Tutup
LinuxCommandLibrary

Emacs Text Editor

Getting Started

Emacs keybindings use a shorthand notation: C- means hold Ctrl, and M- means hold Alt (Meta). For example, C-x C-s means press Ctrl+x, then Ctrl+s.
$ emacs textfile.txt
copy
KeyDescription
C-x C-fOpen a file
C-x C-sSave current file
C-x C-wSave as (write to a different file)
C-x C-cQuit Emacs
C-gCancel current command or operation
C-x uUndo last change

Navigation

Movement commands come in pairs: C- moves by small units, M- moves by larger units.
KeyDescription
C-fMove forward one character
C-bMove backward one character
M-fMove forward one word
M-bMove backward one word
C-nMove to next line
C-pMove to previous line
C-aMove to beginning of line
C-eMove to end of line
M-aMove to beginning of sentence
M-eMove to end of sentence
M-{Move to beginning of paragraph
M-}Move to end of paragraph
C-M-aMove to beginning of function
C-M-eMove to end of function

Editing

Mark a region with C-SPACE to set the start point, then move the cursor to select text.
KeyDescription
C-SPACESet mark (start of selection)
C-x hSelect the entire buffer
C-wCut (kill) selected region
M-wCopy selected region
C-yPaste (yank) last killed text
C-kKill from cursor to end of line
TABIndent current line
C-x C-+Increase text size
C-x C--Decrease text size

Search and Replace

Emacs uses incremental search — results appear as you type.
KeyDescription
C-sSearch forward (incremental)
C-rSearch backward (incremental)
M-%Search and replace (query mode)

Buffers and Windows

Emacs can split the screen into multiple windows, each showing a buffer.
KeyDescription
C-x 2Split window horizontally
C-x 3Split window vertically
C-x 1Close all windows except current
C-x 0Close current window
C-x oSwitch to the next window
C-x bSwitch to a different buffer by name
C-x kKill (close) a buffer
C-x dOpen the directory browser (Dired)

Commands

Run extended commands by name with M-x followed by the command name.
KeyDescription
M-x eshellOpen a terminal shell inside Emacs
M-x goto-lineJump to a specific line number
M-x toggle-word-wrapToggle word wrapping
M-x flyspell-modeToggle spell checking
M-x linum-modeToggle line numbers
M-x visual-line-modeToggle visual line wrapping
M-x compileRun a compile command
M-x package-list-packagesBrowse and install packages

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard
X Tutup