Skip to Content

Emacs tips

Manal's picture

  • examples of Major modes (C++ mode, erc, gnus, etc.).
  • examples of minor modes (spell checking mode).
  • CTRL c (written as C-c) for commands related to the mode u r in.
  • a very important command is CTRL g (C-g), to cancel any command u started writing in the emacs command line.
  • Emacs supports completion of other words in the buffer, using M-/ TAB
  • for changing the default color of emacs, download the color-theme package from the emacs wiki, gunzip it under the elisp/ directory (create it first), then open it using M-x color-theme-select and select a nicer theme.
  • if u want to change the emacs defaults, u have to edit the .emacs file (create it first), and then u have to know some lisp syntax to be able to write ur own preferences.
  • also u can customize emacs through options ---> customize emacs.

Emacs Command:

ALT x (written as M-x) opens the emacs command.

  • ALT x then press TAB, to view all possible commands/functions (tab completion).
  • u type the command to enable/disable functions.
  • M-x eshell ---> opens emacs shell.
  • M-x term ---> opens bash.
  • u can press ESC then press x, instead of typing M-x.

Editor related commands:

CTRL x (written as C-x) for commands related to the editor.

  • C-x C-f ---> open file.
  • C-x C-s ---> save file.
  • C-x C-c ---> quit emacs.
  • C-x d ---> opens dired mode.

Help Commands:

CTRL h (written as C-h) for help commands, also u can access it through F1

  • C-h C-h ---> about help.
  • C-h b ---> key bindings.
  • C-h t ---> interactive tutorial.

Text-editing Commands:

  • C-SPACE ---> set a mark.
    • type C-x C-x to switch between the set mark and the cursor (after C-SPACE).
  • C-w ---> cut.
  • M-w ---> copy.
  • C-y ---> yank/paste.
    • type M-y to browse through the "kill ring" (all what u have copied, cut, killed, selected in the clipboard), after C-y
  • C-k ---> deletes from the point of the cursor to the end of the line.
    • if u press C-k many times quickly, u can kill many lines and when u paste emacs paste them all not only the last line.
  • C-_ ---> undo (when undos end, start redoing).

Multi windows:

  • C-x 2 ---> splits the window in focus horizontally.
  • C-x 3 ---> splits the window in focus vertically.
  • C-x o ---> switches focus to the next window.
  • C-x 0 ---> closes the window in focus.

Major Modes:

  • tramp: ssh through emacs.
  • gnus: news reader and mail client.
  • w3m: web browser, supports tables and images.
  • latex: with the latex-preview minor mode, u can c the generated output of latex while u r writing.
  • psgml: validator editor of sgml, xml, html.
  • erc: irc client.
    • supports nick completion.


Dr. Radut | book