Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Monday, February 29, 2016 at 19:46

GNU Emacs is an advanced text editor from GNU Project. It is extensible and hackable by macros. The name Emacs itself is an acronym from Editing MACroS. GNU Emacs is well-known as a rival to vi editor from UNIX. This article introduces how to install and basic usage of Emacs.

Install GNU Emacs

sudo apt-get install emacs

Run GNU Emacs


To run Emacs in console mode, type command:
emacs --no-window

To run Emacs in graphical mode, type command:
emacs

Use GNU Emacs


The main rule of Emacs keystrokes is C key (Ctrl) and M key (Alt, or Esc). User should remember that Emacs is not vi. In Emacs you use normal arrow keys to navigate cursors and you don't use two different modes (INSERT and COMMAND) like vi.

Basic Keystroke Techniques

  • C = Ctrl key
  • M = Meta key, usually Alt key or Esc key
  • C-x = Ctrl-x; press x when holding Ctrl key
  • C-x C-y = Ctrl-x Ctrl-y; hold Ctrl then press x -> release x -> press y
  • M-x = Esc x; press Esc -> release Esc -> press x
Note: M-x with Alt is different with Esc, in which M-x is pressing x while holding Alt. Both Alt and Esc can be used depends on your need.

List of Common Keystrokes


  • C-x C-s = Save
  • C-x C-w = Save As
  • C-x C-f = Open File
  • C-/ = Undo
  • Up Down Right Left = Cursor navigation
  • Backspace = Delete backward
  • Del = Delete forward
  • C-k = Delete all text starting from cursor position until the end of line
  • C-s = Search (Incremental Search)
  • C-r = Search Backward (Incremental Search)
  • C-g = Cancel a command
  • C-x C-x = Quit
  • C-space = Select/Block text