α
Published on

A very simple guide to GNU Emacs

320 words2 min read
Authors

This guide was written in Emacs editor.

Introduction to GNU Emacs

GNU Emacs is a text editor in GNU project.

Why should we use Emacs for code editing?

  • High perfomancce
  • Many awesome features for programming:
    • Jump to any header file.
    • Autocompletion.
    • Showing function arguments.
    • Quickly comment.
    • And many more features depending on your configuration.

Installation

This guide uses GNU Emacs running on Ubuntu 16.04.

To Install Emacs, you can simply open Terminal and type:

sudo apt-get install emacs

If you're using another operating system, just Google and you can easily find the installation guide for your OS.

Using Emacs

To start Emacs, open Terminal and type emacs& to open Emacs GUI or emacs -nw to open Emacs Terminal.

Basic shortcuts in Emacs

Firstly, in Emacs shortcuts, 'C' will stand for Ctrl key and 'M' will stand for Meta key (Esc key or Alt key on your keyboard).

1.File:

ShortcutDescription
C-x C-fOpen file
C-x C-sSave
C-x C-wSave as
C-x sSave all
C-x C-vRevert to file
M-xRevert Buffer
C-x kClose Windows/Buffer
C-x C-cQuit

2.Edit:

ShortcutDescription
C-_Undo
C-SpaceBegin Selection
C-gCancel Seclection
C-wCut Seclection
C-kCut Line (From current position to the end of the line)
C-yPaste
C-x r s <number>Copy Selection to Numbered Clipboard
C-x r i <number>Paste from Numbered Clipboard
Delete or C-dDelete
M-DeleteDelete Word Before The Cursor
M-dFwd Delete Word

3.Cursor Movement:

ShortcutDescription
M-fWord Forward
M-bWord Backward
C-a / C-eJump to beginning / end of line
M-{ / M-}Paragraph Forward / Backward
C-v / M-vPage Forward / Backward
M-< / M->Jump to beginning / end of file
M-C-a / M-C-eC Function Forward / Backward

Above is a very basic guide to GNU Emacs. You can find more documents about Emacs at : GNU Emacs - GNU Projects.