Skip to content

Instantly share code, notes, and snippets.

@ChetanAhuja
Last active September 16, 2015 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChetanAhuja/42ee8321c906466b601c to your computer and use it in GitHub Desktop.
Save ChetanAhuja/42ee8321c906466b601c to your computer and use it in GitHub Desktop.

First.. what is all this C-x-y-Alt-Escape stuff? Do I need 12 fingers to use Emacs?

No you don't.

C-something is a key-chord that means pressing "something" while already holding down the control key

C-something C-other means just those two key-chords done in sequence. Typically you achieve that by pressing Ctrl, then pressing "something" and then press "other" and then release the Ctrl.

C-something-other means, hold down Ctrl and then press "something". Release both. Then press "other"

M-x is a key-chord that means pressing 'x' while already holding down the "Meta" key. Btw, Meta is just Emacs's way of saying "Alt" (on PC style keyboards) or "Option" (on Mac style keyboards).

M-x is the magic incantation to emacs to give it a full named command. all the C-x... etc. key chords are basically just keyboard shortcuts to complete named commands. You can try running each of the shortcut commands by their full names using the M-x magic.


Now the three basic keyboard commands to edit a file:


C-x C-f find-file ("Open")

and choose an existing file or give it a new filename. Emacs likes to take input at the bottom line of the working area. This is true for every command requiring some input.

Make some edits. Just type like you would in any modern program and expect it to behave accordingly.

C-x C-s save-buffer ("Save").

open working areas (generally with disk files open in them) are called "buffers". This command saves this

C-x C-c save-buffers-kill-emacs ("Quit")

(Exit but before that, ask to save every unsaved open file... like you'd expect any modern program to ask)

You just edited a file in emacs.


Learn Some other stuff


Region (Selected area)

Selection area is called "Region": It's the area between "mark" which you can set anywhere by hitting a key combination ( C-Spc ) and then navigating the cursor ("point") to any other place in the "buffer".

Once you have a buffer selected, you can "kill" (cut) it. Then you can "yank" (paste) it somewhere else.

If you're wondering what the heck is up with the emacs inventing different terms for all your familiar word processing concepts, note that emacs development actually predates all the familar word-processing programs that popularized the Open, close, cut, paste etc. terminology. So it's not so much that emacs invented unfamilar terminology, it's just that unfamiliar technology got invented and entered common parlance while emacs remained a niche product for programmers.

Buffers ( C-x C-b list-buffers )

This brings up the list of currently open files (or other temporary data areas of emacs) by splitting the "frame" into two "windows". You can hop between these two windows by pressing C-x-o . Then you can decide to "visit" any of these buffers by using the arrow keys to get to the correct row in the buffer list and hitting enter.

Moving around

C-v scroll-up (by a full screen)

M-v scroll-down (by a full screen)

M-> end-of-buffer (go to the last line of the buffer)

M-< beginning-of-buffer (go to the last line of the buffer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment