- Most used keys
- Navigation
- Editing
- Multiedit
- Search
- Org related
- Good to know
- Update Doom
- Install required files
Updated: 2022-08-01
Some tips to learn the keybindings in Doom and Evil in the process of migrating
from my vanilla Emacs settings. For overview of keybindings type
SPC-h-b-b
. Other good references:
- Narra’s Blog - Doom Tips and Howtos
- Org Mode Shortcuts for Emacs Doom
- Gist of Hjertnes
- Evil-mode collection
Nice Doom Emacs Cheatsheet from niyumard.
Doom leader-key is SPC
and localleader-key is SPC-m
. When in Insert mode
use M-SPC
or M-SPC-m
to call the menu available as in the Normal mode.
Else change mode with ESC
or jk
binding. To toggle between Emacs state and
Evil use C-z
.
To show all your keybindings SPC-h b b
Most used keys
There are keys I mostly need to remember and there are also listen in their respective groups below:
Normal mode
zx
kill bufferSPC-w w
move to bufferzz
center lineM->
andM-<
go to end or start of the bufferSPC-i r
insert from evil-register or0p
when you know it’s register number0
in evil register or 1,2,…di(
andyi(
is both delete and yank inner words respectively.ciw
change/clear the inner word under the cursor and move to inner mode.cw
change/clear from cursor position to next whitespacecs"'
change/clear the surround or delimiter"
to'
symbolSPC-s s
search word or/
.SPC-TAB .
change workspace.
Insert mode
C-w
kill word bakwordM-d
kill word forward
Visual mode (v) or Block Visual mode (Ctrl-v)
viw
select word under cursor or inner word under the cursorvio
select all inner and inclding a symbolva(
selecte all around the bracket(
or any specific symbol that you can specify eg.va"
C-vjjI
edit multiple linesg ;
andg ,
go to last change in the current buffer forward or backward
Navigation
When in the Normal mode:
C-b
andC-f
for page backward and page forward (whole page)C-u
andC-d
for half page up and downz-z
move line to center of screenM->
andM-<
go to end or start of the buffergsj
andgsk
go to line downward (j) or upward (k) ie. avy-gotogsf
andgsF
go to forward (f) or backward(F) for selected letterfw
andFw
findw
or any word/symbols specified forward or backward in a line. Move to next foward or backward withf
g;
andg,
go to last changed same buffer forward and backward''
andC-i
andC-o
jump to previous cursor forward or backwardma
to mark position as a and use'a
to go to the line where the mark is or`a
(backtick) to go to the position of the marked ie.a
Shift-L
andShift-H
moves cursor to lower (L) or higher (H) screenShift-M
moves cursor to the middle of the screen- Split windows with Evil shorcut
:sp
or evil-window-splitC-w s
or evil-window-vsplitC-w v
. SPC-s d
search current directory orSpc-s p
current projectSPC-'
resume last search%
move to matching paranthesesSPC-b-l
orSPC-`
move to last buffer
Editing
In Normal mode:
db
delete backward till next whitespaced$
delete to end of line from cursord0
delete to start of line from cursords(
delete columns or any parantheses specify afters
ie. symbolscw
kill from cursor position to next whitespace4cw
kill 4 words (or any number) forwardci{
kill all within the curly bracket when the cursor is inside. Other symbols can also be specified and when cursor is inside the specified symbols all text inside will be deleted.[o
and]o
will insert newline above or below respectivelyC-j
will cut/split the sentencegU
for UPPERCASE orgu
lowercase org~
to toggle between:e
edit file:w
save fileviw
select a word under the cursor*
select all word under the cursor in the buffer#
select all word in the same line/
search wordvio
select all inner and inclding a symbolva(
selecte all around the bracket(
or any specific symbol that you can specify eg.va"
di(
andyi(
is both delete and yank inner words respectively.ciw
change the inner word under the cursor and move to inner mode.Spc-s s
search word orfw
andFw
S-"
surround the selected word ie. in visual mode, with selected symbol eg."
in this case.g-S-"
surround the selected word with symbol with additional newlinecs"'
change the surround or delimiter"
to'
symbolds"
to delete the delimiters"
In Insert mode:
C-w
delete word backward
In Visual mode:
- Block all line and press
=
to do indentation
Multiedit
In a file one at a time
Doom uses multiedit package otherwise it’s like multiple-cursors package plus iedit
package. Basic keybinding is M-d
or M-D
. It works both in Normal and
Visual mode.
In Normal mode, when the course under a word, pressing M-d
will select the
word, repeating M-d
mark forward and M-D
mark backward. Use C-n
and C-p
for next and previous selected word. In Visual mode, when you have made
selection pressing R
will select all the marked section in the whole document.
Press Enter
to deselect or reselect the marked section.
All in a file
Select the text then R
Search and replace in a project
- Search the text with
SPC-s p
. - When all the files are listed, enter swiper edit with
C-c C-e
. - Select the word then multiedit all word with
R
key, then edit. - Save the file with
C-c C-c
or cancel withC-c C-k
.
Add text at first line of multiple lines
This is when you want to change multiple first lines (Ref.):
- Move cursor to the first line
0
. - Enter visual block mode
Ctrl-v
- Press
j
multiple times (or5j
) to jump by 5 lines, orG
to jump to last line. - Press
I
(capital i). - Type the word to add. Note: it will only update the screen in the first line
until
Esc
is pressed, then all lines will be updated. - Press
Esc
.
Search
Different approach to search
Project
SPC SPC
find file in projectSPC s p
search project for textSPC s d
search files in directory for text
M-x consult-ripgrep
Nice function for flexible search
#alpha beta
search for alpha and beta in any order#alpha.*beta
search for alpha before beta#\(alpha\|beta\)
search for alpha or beta#first#second
search for first, quick filter for second
Regular expression
- To find unmatched quote using this regex
^[^"]*"[^"]*$
Online search
SPC s o
search onlineSPC s t
search online dictionary
Org related
SPC-m-h
to change to headingSPC-m-i
to change to itemShift-TAB
to move backward in table
Good to know
SPC-h-v
orC-h v
to check the value or default value of any function.SPC-TAB-TAB
change workspaceC-x C-t
transpose lineM-t
transpose words
Update Doom
Usually it should work to update Doom by running
~/.emacs.d/bin/doom upgrade
~/.emacs.d/bin/doom sync
But if it fails, you can delete the package that fails. For instance if package
gcmh
fails then
rm -rf ~/.emacs.d/.local/straight/gcmh
doom sync
The easiest is to delete folder .local/straight
entirely before doom sync
.
Or pull everything and re-install
cd ~/.emacs.d
rm -rf .local
git pull
bin/doom install
Install required files
You need to install some prerequisite to make doom work properly. Among them:
-
ripgrep
To ensure you install the newest release, you can check it here ripgrep releases.
cd ~/Downloads
curl -LO https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep_13.0.0_amd64.deb
sudo dpkg -i ripgrep_13.0.0_amd64.deb
-
+spell
If you use
+spell
then you need to installhunspell
.
sudo apt install hunspell