Doom Emacs Cheat Sheet



Emacs or EMACS (Editor MACroS) is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as “the extensible, customizable, self-documenting, real-time display editor”. 07 the only cheat sheet you need 08 Over 225 terminal color schemes/themes for iTerm/iTerm2. Includes ports to Terminal, Konsole, PuTTY, Xresources, XRDB, Remmina, Termite, XFCE, Tilda, FreeBSD VT, Terminator, Kitty, MobaXterm, LXTerminal, Microsoft's Windows Terminal, Visual Studio, Alacritty. Emacs must be installed and run as normal. Spacemacs is not a separate application. A lot of the niceties detailed above are already included in spacemacs but installing cider is slightly different. To setup spacemacs from scratch first remove all traces of emacs config files then install the spacemacs config to /.emacs.d: cd mv.emacs.d.

What is Emacs?

Emacs is a Lisp interpreter. It is commonly used as a text editor for reading and writing code, although you can useit to write academic documents or do your taxes, if that is more your style. It has a very rich history and it is almostcertainly the most flexible text editor that is publicly available. As such, it tends to be the case that one dev’s useof Emacs is very different than another’s.

Where to get Emacs?

Sheet

MacOS:

Windows:

  • You may want to look into WSL as well

Linux:

  • Instructions for Snap (26.3, stable and recommended if you choose snap)

Catchall:

  • Build from source (GitHub Mirror)

Note

This spotlight has a tendency to change tenses and focuses. This is because it was written by 5 separate people. Emacsalso has quite a bit to offer. This spotlight was written to share and introduce Emacs, not necessary make experts norconvert everyone. There wasn't a need to go into the nitty grity details until the free Q&A portion of the spotlight. Ifyou have any remarks or fixes, feel free to make a pull requesthere. If you require some help or clarification, thetech champions (as well as other TPHers) are available in the discord on the#editors channel. Feel free to drop by and say hi. There are a few memes that kept us sane scattered around.

Why Emacs?

Many people look at how poor the out of the box experience with Emacs is, compare it to VS Code and dismiss Emacs as anoption, stating that it’s simply too difficult to use, it’s ugly, and that concludes their experience with Emacs. I’mgoing to attempt to persuade you for a few moments of the following points:

  1. The out of the box experience with Emacs doesn’t have to be so barebones.
  2. The learning curve is actually substantially lower than you might think it is.
  3. Emacs is capable of much more than any other editor is, generally speaking.

Let’s address these points in order.

Point one: The Emacs out of the box experience

It is absolutely true that Emacs seems to be barebones and archaic when first used. Let’s take the example average user:They download VS Code first and attempt to use it, it has syntax out of the box, you open a JavaScript file and it says“Hey, do you want to download X, Y and Z plugins?”, they click “yes” and they’re ready to edit some JavaScript. Thenthey download Emacs, they run it, they are presented with some screen about how Emacs is “one component of the GNUoperating system” and a bunch of links. Immediate questions:

  • How do I open a file?
  • How do I “do things”?
  • Why are the blue links in my face and a handbook link?
  • Why isn’t the window full screen?

This is not how Emacs should be used. Emacs is not a text editor, it is only incidentally a text editor. Emacs is muchmore like an application framework, inside of which you have control over everything. This application framework iscontrolled by Lisp, in specific, Emacs Lisp. You know nothing of Emacs Lisp or Emacs and you just opened Emacs up, howcan you expect to be anything except confused?

So we have this apparent complexity issue with Emacs, and we want to be pragmatic in the same way that we were when weopened VS Code, without any extra information, we started coding. We’re going to have to sacrifice a small amount here,in that we need to install an extra thing in order to get that same kind of out of the box experience.

(For the savvy people, we're going to use spacemacs as our clutch since most of use areusing custom configuration. We highly recommend looking into other distributions like DoomEmacs, especially if you want to give Emacs a second shot and see how fast itcan get).

Open a terminal and execute the following command:

Note: For Windows users, you will need to point the last part of the command ~/.emacs.d to wherever you have setyour home directory to. (A neat treat to check where to install: open emacs as is [yes yes, we're sorry your eyes burn];type in M-x user-emacs-directory RET; where M is your meta key which tends to the alt key, M-x is pressing metakey and x key at the same type, you type out user-emacs-directory, and RET is enter; this should show you the pathyou'll want in place of ~/.emacs.d).

This will install Spacemacs for you. Spacemacs is an out of the box experience for Emacs, which you will need toconfigure and change very little. When you first open Spacemacs, it’ll ask you some questions, one of the questions isdo you want to use Holy or Evil mode. If you are familiar with vim, select evil mode. If not, select holy mode (Holymode is the regular, default Emacs, without evil mode, sometimes referred to as “vanilla” Emacs. Evil is vimkeybindings).

Doom emacs os x

What this will do is install a sane, default configuration for you. There is very little learning that goes intolearning Spacemacs initially. We’ve documented it later. If a good out of the box experience is super key for you, it’srecommended that you use a distribution like Spacemacs, as that is the singular focus of distributions.

Point two: The Emacs learning curve myth

A lot of times people will associate Emacs with having a very steep learning curve. This is not true on any frontactually, even for the base, clunky, ugly Emacs you saw earlier. The reason for this is that Emacs is actuallyself-documenting. It does a really good job of helping people to learn it, you just have to be willing to learn it. Itcan take 1 - 2 days to get very familiar with all of the basics (Described in the basics section) and then maybe afurther 1 - 2 weeks to be as productive as you were before. After that, the sky's the limit. We’ve included some basicconfigurations for a lot of common programming languages in tphmacshere, written in such a way that youcan just pop them into your configuration.

Additionally, packages like “which-key” and“discover-my-major” can help you learn very complex packages/ pluginsvery trivially. I almost never have to google stuff to figure out how to use Emacs because just asking Emacs is fasterthan asking google.

Point three: [Generally] Emacs is capable of much more than any other editor

So up until this point, we’ve just been laying out the ground work which indicates what makes Emacs equal to your oldeditor. It’s certainly the case that Emacs isn’t as good in some specific cases, for example, with Kotlin. This languageis quite the edge case, though, as it’s usually the case that for newer languages Emacs is very good. However, generallyspeaking it’s an equal playing field, all things considered.

So what can Emacs do that your current editor might not be able to? Below you can find a short list of items thatdemonstrate the raw power present within Emacs, that might help to persuade you to use it.

  • Emacs can be used as a Window manager using EXWM. Say goodbye to i3wm.
  • Emacs has a web browser built into it (EWW) - the name is fitting because it’s not pretty, but I’ve used it so manytimes for just quickly jumping to a link from the comfort of my editor.
  • Emacs allows you to write a literate configuration file. This means that the configuration file you have in Emacs issuper easy to understand. (Anecdote in bound) Back when I was using vim, I had a very long .vimrc which essentiallyconsisted of stuff that I had copy/pasted from stack-overflow, that I had no real understanding of. In Emacs, I’ve mademy entire configuration file myself, and I can understand it all, because it’s just code with associated documentation.
  • Emacs has Eshell, which is actually significantly more powerful than the regular terminal you are used to. It is aLisp REPL as well as a fully fledged terminal. This can be immensely powerful. Additionally, because Eshell outputs tojust a regular text buffer inside of emacs, you can search, yank, paste, and manipulate text in the same way that youcan throughout the rest of Emacs.
  • Org mode is one of the most powerful document formats available, and it requires no special encoding to use it, it’sjust a plain text file. You can hook it into pandoc, too. It’s worth noting that you can export to LaTeX and it’s muchmore ergonomic than regular LaTeX.
  • Vim emulation inside of Emacs is basically perfect. If you are persuaded by any promise that you can find from vim,Emacs has the ability to use everything inside of vim.

Emacs Basics

Keybinding Syntax Basics

Sequence of keys:a b c d represent the following sequence of key, a then b then c then d

Key modifiers: They are followed directly by a -, they represent 'special' keys such as control, alt, the 'windowskey' and so on. They are meant to be used simultaneously with other keys, such that C-x means pressing control + x atthe same time. The list of available modifiers:

  • C, the control key
  • M, the meta key, commonly bound to alt or option
  • s, the super key, also known as the 'windows key'
  • H, the hyper key, which is usually unbound by default on most systems
  • A, the alt key, which is also unbound, this is not the actual alt key

Keychords: They're represented by one or more modifiers followed by a dash and any key, such that C-b is control+band M-s-s is meta+super+s

Holy Mode Users

Humble note: commands tend to start with C-x or C-c with holy bindings. With that, here are some basic operationseveryone user needs with holy keybindings:

Open a file:C-x C-f (f is for FILE)

Save a file:C-x C-s (s is for SAVE)

Searching:C-s (s is for SEARCH) OR C-r to search backwards from current point (r is for REVERSE)

Quitting Emacs:C-x C-c

Stuck in the middle of a command?: Mash C-g!

Evil Mode Users

The first obvious question to ask here about operating an evil-mode configuration is “how close is evil mode to regularvim”. The answer is: Very. Certainly as a long term vim user, I’ve never noticed anything out of place. So if you haveread vimtutor, all of that applies here.

Evil Operations

Some basic operations for you, I have taken the liberty of writing the mnemonic with them:

Open a file: In normal mode :e <file name> (e is for EDIT)

Save a file: In normal mode :w (w is for WRITE)

Searching: In normal mode /<search>

Delete a file: In normal mode !rm <file.txt> (rm is for REMOVE)

Some evil mode notes

Personally, I don’t use the file operations from evil mode. I just use evil mode for the text navigation andmanipulation. For searching I use swiper which I’ve bound to C-s, and I use Helm to find my files. Counsel with ivy isa popular alternative to Helm. That’s the beauty of it, you can mix and match whatever makes more sense to youpersonally.

Other General Points

Buffers and Windows

Emacs' terminology relating to what people usually refers to as windows and buffers is different, it's important to atleast roughly know the difference between them as these terms will be used later on.

A buffer refers to the dataassociated with a certain type of file or action, for example the content of a file, a terminal emulator or animage. They can be hidden or displayed in a window.

A window refers to a panel or split inside a frame, it is used todisplay a buffer.

A frame in emacs refers to the graphical window you are using emacs in, it contains windows, youcan have multiple frames per Emacs instances.

Here is a more detailed explanation on stackexchange with an illustration.

Major and Minor modes

Modes are Emacs' way of understanding what you are doing and what you want to do. All all time you have one activemajor mode and 0 or more active minor modes. A mode can alter the behavior of emacs in many ways, such as changingkeybindings, changing the display of the buffer, enabling auto-completion, modify an existing function, the list goeson.

Major modes provide ways to interact with specific file types, like a file containing source code, or a specific buffer,like an interpreter or a git interface. Minor modes are just like major modes, but you can have multiple of themenabled at the same time, an example of a minor mode is line-number-mode which displays the line numbers in yourmodeline and isn't specific to a file type.

There are multiple ways to enable a mode:

  • Manually, by invoking the mode like a function eg. (line-number-mode t)
  • By using the variable auto-mode-alist to associate a major mode with a file extension, (add-to-list 'auto-mode-alist '('.py' . python-mode))
  • By using hooks, which will run the modes like functions when the hook is triggered, (add-hook 'prog-mode-hook#'line-number-mode) By default, the appropriate major mode should activate automatically depending onfile extension, just like in any other editor.

Dired Mode

Emacs includes a _dir_ectory _ed_itor mode called dired that lets you view directory contents, traverse directories,and manipulate files, just like you would in a normal shell. A cheat sheet is availablehere, and see this section in themanual for all the details.

Eshell/Term/other terminals

Doom Emacs On Windows 10

Because of Emacs’ long history, there are a number of solutions for accessing terminal functionality. Furtherexplanations are in stackexchange here.

  • M-!: not a full-featured shell, but lets you run a single command quickly, like ! in vim.
  • Shell: The original Emacs terminal implementation. Because of how it runs the underlying shell, its color displaysupport is flaky and curses apps don’t work.
  • Term and ansi-term: A newer terminal implementation, where everything looks and works closer to what you’dexpect. You probably want ansi-term, which will open a new buffer with a fresh terminal every time it’s called.
  • Libvterm: A much more performant and customizable terminal, but needs (use-package vterm) and for Emacs to becompiled using --with-modules.
  • Eshell: Unlike all the other emulators, this one lets you evaluate Elisp directly at the prompt. See this sectionin the manual for how to best take advantage ofthis power.

Distributions

Setting up Emacs is hard, here are some prebuilt Emacs distributions you might want to try https://www.spacemacs.org/https://github.com/hlissner/doom-emacs Doom is Spacemacs taken to the extreme: very opinionated, evil only, anddesigned to go fast. http://www.emacs-bootstrap.com/ Interactively generate a config with only the languages you careabout. If you want a non-Spacemacs experience, closer to what you’d get if you configured Emacs from scratch, but in aliterate style https://en.wikipedia.org/wiki/Org-mode, use our config wholesale: git clone https://github.com/the-programmers-hangout/emacs.git ~/tphmacs; ln -sv ~/tphmacs ~/.emacs.d. Pull requests welcome!

Resources

Doom Emacs Os X

  • Zaiste’s Doom Emacs Tutorials(in particular, the Magit videos are good and not Doom-specific)

Fun Facts

  • Some users use vs code and whatnot, but pop open Emacs just for Magit because it'sjust so amazing.
  • Again, some other editor users pop open Emacs just for Org-mode.
  • The butterfly command from XKCD 378 exists, try M-x butterfly RET.
  • Some wild Emacs spottings in Tron: Legacy found by redditorshere.
  • Famous Emacs Users (that are not famous for using Emacs)
    • you'll definitely recognize quite a few names....

End Note

Happy Emacsing!

Introd­uction

The principles of Crime Prevention through Enviro­nmental Design (CPTED), a layered approach that emphasizes barrie­r-free observ­ation, easy access control and clear boundary marking in addition to the same upkeep you’re probably already doing.
Any site or building type can benefit from integr­ating the principles of CPTED. Famili­arize yourself with the tenets of this common­-sense design philosophy and learn how to spot red flags at your building.Credit: https:­//w­ww.b­ui­ldi­ngs.co­m/a­rti­cle­-de­tai­ls/­art­icl­eid­/21­405­/ti­tle­/wh­o-s­-wa­tch­ing­-yo­ur-­fac­ility-

CPTED Basics

CPTED is a layered approach combining four princi­ples: natural survei­llance, natural access control, territ­orial reinfo­rcement and mainte­nance. All four work together to create an enviro­nment that both makes potential criminals uncomf­ortable and enables occupants to notice anything out of place.

Principle 1: Natural Survei­llance

Natural survei­llance is charac­terized by two comple­mentary goals: minimizing ambush points and enabling the unobst­ructed observ­ation of people with malevolent intent. Landsc­aping and lighting mistakes are the two biggest areas of neglect where this principle is concerned, followed by interr­uptions in lines of sight.
Ideally, you should be able to see someone approa­ching from a consid­erable distance without any visual obstacles getting in the way, Ahrens says. “A good example is those car lots that look like Las Vegas, where you think ‘How much money are they spending on all that power?’ Well, if you were actually in the parking lot looking out to the foregr­ound, you wouldn’t be able to see anything because where you are is so bright. However, the person in the background looking into the parking lot can see bright as day. The psycho­logical component is ‘Who’s watching me while I’m in this parking lot?’ Thus we’re going to attract legitimate activity from people who want to buy a car. People who have illegi­timate intent and are seeking to steal headlights or a car will be deterred because they would be observed or someone would call the police.”

CPTED Companion Concepts

Principle 2: Natural Access Control

This principle relies on using pathways, lighting and other means to direct traffic and define spaces for use. For example, instead of an open park where anyone can walk anywhere. Creating paths and use plantings to create borders.
Natural access control is closely linked with natural survei­llance, adds Audra Rigby, Principal of Certified Crime Prevention Consul­tants. Pathways and boundaries should be distinct enough to smoothly direct people from place to place but not obtrusive in a way that interferes with a clear line of sight. With landsc­aping, for example, Rigby recommends limiting small plantings or hedges to 2-2.5 feet and trimming tree canopies starting at 6 feet from the ground. “That allows for survei­llance in and out of the building and the landsc­aping won’t block windows,” Rigby add

Principle 3: Territ­orial Reinfo­rcement

Similar to the principle of natural access control, territ­orial reinfo­rcement focuses on drawing clear lines between different properties and public areas vs. private ones by using both hard barriers (fences and walls) and soft barriers (plantings and lighting), as well as clues like artwork and entryways. “That eliminates all of the possible excuses people might have about why they’re not complying with the rules, such as why they’re parking in a certain area or why they’re on one side of the building,” Hushen explains.

Principle 4: Mainte­nance

The importance of mainte­nance is supported by the broken window theory in which well-kept properties indicate to offenders that someone is watching the area, Rigby explains: “Maint­aining the urban enviro­nment creates an atmosphere of order and lawful­ness, which helps reduce the opport­unity for crime on the property.”
Conver­sely, rundown and dilapi­dated properties evoke the idea that no one is watching and the property is abandoned, which invites vandalism, littering and worse. Poor lighting has the same effect, Ahrens adds; good lighting is one of the best ways to deter crime, but if you cut too many corners or don’t maintain the lighting system, you could be asking for trouble.