Malcolm Bastien Flow Focused 🌊

My Emacs Writing Setup

Doom Emacs

Doom Emacs

I decided to use Doom Emacs. When I first started I actually spent a few days trying to start from scratch, by following some tutorials and installing a few plugins I was able to get something pretty good, but the ceiling or limit to what Emacs can do is so high. I resisted it a bit at first, but I eventually made the decision to offload the work on creating a crafted Emacs experience people who have been this for years, and with that decided to install Doom Emacs.

Plugins

Here’s a subset of the plugins I’ve enabled in Doom Emacs related to writing:

  • zen
  • undo
  • syntax
  • grammar
  • markdown

A lot of what you need from Doom Emacs is enabled by default.

One of Emacs default behaviours I didn’t like was how moving the cursor up or down would skip wrapped lines.

To fix that, I needed to add this to my config.el file

(map! :nv "j" #'evil-next-visual-line
      :nv "k" #'evil-previous-visual-line
      :nv [up]   #'evil-previous-visual-line
      :nv [down] #'evil-next-visual-line)

Shortcuts

There’s a plus and minus to using a keyboard driven application. On the plus side, you can execute commands and navigate very quickly. But the negative is that until these commands and actions become muscle memory, things are very slow.

One thing I appreciate about Emacs is how you can search through every available command by using the hotkey M x or (Alt + x). It helps, but the there are so many actions you need to learn the hotkeys for. I tried saving all the shortcuts i thought would be important in Obsidian.

Finding/Saving Files

KeyDescription
SPC SPC or SPC p fJump to file in project (like Atom/Sublime Text’s goto-anywhere)
SPC . or SPC f fExplore files in current directory
SPC f S-fJump to file under current directory (recursive)
SPC f sSave file
SPC f S-sSave file as (prompts for location)
SPC o pInitialize or toggle treemacs
SPC o Pfind and focus the current file in the treemacs window

Leaving Emacs

KeyDescription
:qaQuit Emacs
:wqaSave all buffers and quit Emacs
SPC q qQuit Emacs
SPC q rRestart Emacs and restore session

Search (and Replace)

KeyDescription
SPC / or SPC s pSearch across current project
SPC s S-pSearch another project (prompts you to select one)
SPC s dSearch in current directory (recursive)
SPC s S-dSearch in another directory (recursive)

Buffer Management

KeyDescription
SPC , or SPC b bSwitch to another buffer
SPC < or SPC b S-bSwitch to another buffer across workspaces

Window Management

KeyDescription
SPC w sSplit the window horizontally
SPC w vSplit the window vertically
SPC w dDelete current window
SPC w {h,j,k,l}Select window in direction (left, below, above, right, respectively)
SPC w {S-h,S-j,S-k,S-l}Swap current window with window in direction
SPC w {C-S-h,C-S-j,C-S-k,C-S-l}Move current window to edge of frame in direction
SPC w u or C-w C-rUndo or redo last change to window configuration
SPC w oEnlarge current window. Again to undo.
SPC w m mDelete other windows. Again to undo.
{N} C-w |Change width of current window to N (a number)
{N} C-w _Change height of current window to N lines

Font Size

KeyDescription
C--Decrease font size
C-=Increase font size
C-+Reset font size

Writing

KeyDescription
SPC t zToggle Zen mode
SPC t ZToggle full-screen writeroom-mode
g s SPCJump to character
M {up, down}move section up or down
z nCreate indirect buffer and narrow it to current sub-tree
z NWidens narrowed buffers
SPC m s nNarrow buffer to the current sub-tree
SPC b cClone indirect buffer
SPC b CClone indirect buffer to another window
SPC w dDelete current window

Modifying Text Objects

KeyDescription
c t [char]Change until target character
c i wChange inner word
c i "Change inner quotes
c a "Change around quotes
D,d $Delete from cursor to the end of the line
C,c $Change from cursor to the end of the line
xDelete a single character under the cursor
rReplace a single character and stay in Normal mode.
oOpen a new line below the current one and enter Insert mode.
OOpen a new line above the current one.
>Right indent
<Left indent
=Indent text
~Invert case of character
uUndo.
C-rRedo.

Jumps

KeyDescription
wJump to the start of the next word.
eJump to the end of the next word
bJump back to the start of the previous word
0Jump to the absolute start of the line
^Jump to the first non-blank character of the line
$Jump to the end of the line
f [char]Find the next occurrence of a character on that line
%Jump between matching brackets
:[number]Jump to a specific line number
C-]Jump to tag under point
JAN 16
[CREATED]
Refactor: Rename posts to notes and update references
+158 -0
46ce7cd