in Code, Geeklife

Emacs Pocket Guide

I wrote this a long long time ago when I was learning emacs, then pasted it on, but that site is down atm.
So here’s for future reference


Ctrl+g          Cancels anything (useful for n00bs)

== Saving ==
Ctrl+x s        Save buffer (buffer a.k.a filez)
Ctrl+x Ctrl+w   Save As

== Opening and switching buffers ==
Ctrl+x Ctrl+f   Para abrir buffers (archivos)
Ctrl+x k        Close buffer
Ctrl+x b Enter  Switch to previous opened buffer

Ctrl+x b Tab
Ctrl+x Ctrl+b   Show list of open buffers

== Looking at several buffers at the same time ==
Ctrl+x 2 Split buffer with horizontal bar
Ctrl+x 3 Split buffer with vertical bar
(You can subdivide the screen up to like 64 viewports)

Ctrl+x 1 unsplits everything, only 1 buffer at the time

Ctrl+x o Switch focus to next split buffer

== Select, Copy, Cut, Paste ==
Ctrl+spacebar   Mark the beggining of a text region
Ctrl+w          Wipe (a.k.a Cut)
Alt +w          Copy
Ctrl+y          Paste
Ctrl+k          Cut from the cursor to the end of the line
Ctrl+u          Cut from the cursor to the beggining of the line

Also everything that you select with the mouse will be on the clipboard
and you can paste with middle click (or two button click if you have a 2 button mouse)

Alt+x transient-mark-mode  Makes you see what the selection looks like (highlighting)

Ctrl+d Delete in front of cursor (DELETE)

== Moving around (Search, Replace, Moving cursor fast) ==
Ctrl+s texto   Forward Search
Ctrl+r texto   Reverse search

Once you start the search, press Ctrl+S again, or Ctrl+r to 'keep-on-trucking'
You can stop with the arrow keys, or pressing enter.

Alt+x query-replace Search and replace interactively
                    Press 'y' to replace, 'n' to skip and keep searching

Alt+x replace-string Search and replace everything

Alt+x query-replace-regexp  Interactive Regexp Search and Replace
Alt+x replace-regexp        Non-Interactive Regexp Search and Replace

Alt+f      Move one word forward
Ctrl+right Move one word forward (won't work on console emacs, X-Emacs only)
Alt+b      Move one word back
Ctrl+left  Move one word back (won't work on console emacs, X-Emacs only)

Ctrl+up   Move one paragraph up (X-Emacs only)
Ctrl+down Move one paragraph down (X-Emacs only)

Alt +v Page up
Ctrl+v Page down

Esc <  Go to the very beggining of the buffer
Esc >  Go to the very end

Alt+x goto-line  Go to a line number

Since doing goto-line like that is too long, add a shortcut on your .emacs
(define-key esc-map "g" 'goto-line)
Now it'll work with Esc-g

Ctrl+shift -
Ctrl /          UNDO

== Sorting ==
Alt+x sort-lines Sort lines alphabetically

== Indentation y Code Completion ==
Alt +   Word completion, repeat as necessary (must have typed the word on any of the opened buffers)
Ctrl+Alt +   Audo Indents based on the mode (java, python, php...)

Alt+x font-lock-mode Puts syntax coloring
Alt+x c-mode  C style coding
Alt+x java-mode Java style coding
Alt+x html-mode get it.
Alt+x python-mode
Alt+x php-mode

Alt+u Make rest of a word upper case and go to end of word
Alt+l Make rest of a word lower case and go to end of word
Alt+c Make current char upper case and go to end of word

Esc =  If you have a text region selected, see statistics about it.

Ctrl+x = Shows current position of cursor

Complete reference here

by Gubatron

Write a Comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.