Tuesday, June 25, 2019

My own Emacs Reference Sheet

It's my own obligatory Emacs Cheat Sheet.  This is for my own future reference, but here for anyone else that may find it more useful than the multitude of other guides out there.

Modes


  • Emacs works in modes, both major and minor  
  • You can only have one major mode active at a time
  • You can open multiple minor modes
  • Major modes are usually auto-selected based on file type that you opened, but you can manually switch it with M-x <name>
  • Modes usually end in "-mode", e.g., web-mode.el
  • List of modes on Emacswiki
  • More modes can be installed with ELPA / MELPA

Moving Around

  • C-f / M-f ⇒ Forward (char) / Forward (word)
  • C-b / M-b ⇒ Backward (char) / Backward (word)
  • C-p ⇒ Previous (line, i.e., up)
  • C-n ⇒ Next (line, i.e., down)
  • C-v / M-v ⇒ Page down / Page up
  • C-a ⇒ Beginning of line (i.e., "Home" key)
  • C-e ⇒ End of line (i.e., "End" key)

Files

  • C-x C-f ⇒ find (open) file... creates file if it doesn't exist
  • C-x C-s ⇒ Save (current buffer)
  • C-x s ⇒ Save (all buffers)
  • C-x C-c ⇒ Exit w/o saving

Windows

  • C-x 2 ⇒ split screen into 2, horizontally
  • C-x 1 ⇒ close all other windows
  • C-x o ⇒ jump to other window
  • C-x 4 f ⇒ open file into other window (split)

Buffers

  • C-x C-b ⇒ List all buffers
  • C-x b ⇒ Switch to buffer (TAB for auto-complete)
  • C-x k ⇒ Kill (close) buffer (default: current buffer) 

Forays into Emacs, part 1

I've been wanting to learn Emacs for a while now, and over the past few days I've forced myself to really dive into it.  It is overwhelming at first, and I didn't really get into it until I finally figured out how to install the package manager, change the theme, and download a useful package for web development (web-mode.el).

Lessons learned:

  • Take the built-in tutorial, and DO the exercises
  • Memorize ONLY the basic commands, you'll get the rest later
  • Figure out how to use the built-in help
  • Install the package manager ELPA / MELPA 
  • Find a use-case for why you're learning EMACS - mine was web development, and luckily I finally found a major mode that seems to fit the bill: web-mode.el
  • Practice using the new keys for your major / minor mode