- 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
zxkill bufferSPC-w wmove to bufferzzcenter lineM->andM-<go to end or start of the bufferSPC-i rinsert from evil-register or0pwhen you know it’s register number0in evil register or 1,2,…di(andyi(is both delete and yank inner words respectively.ciwchange/clear the inner word under the cursor and move to inner mode.cwchange/clear from cursor position to next whitespacecs"'change/clear the surround or delimiter"to'symbolSPC-s ssearch word or/.SPC-TAB .change workspace.
Insert mode
C-wkill word bakwordM-dkill word forward
Visual mode (v) or Block Visual mode (Ctrl-v)
viwselect word under cursor or inner word under the cursorvioselect all inner and inclding a symbolva(selecte all around the bracket(or any specific symbol that you can specify eg.va"C-vjjIedit multiple linesg ;andg ,go to last change in the current buffer forward or backward
Navigation
When in the Normal mode:
C-bandC-ffor page backward and page forward (whole page)C-uandC-dfor half page up and downz-zmove line to center of screenM->andM-<go to end or start of the buffergsjandgskgo to line downward (j) or upward (k) ie. avy-gotogsfandgsFgo to forward (f) or backward(F) for selected letterfwandFwfindwor any word/symbols specified forward or backward in a line. Move to next foward or backward withfg;andg,go to last changed same buffer forward and backward''and`` jump to mark-line and goto-mark but works as jump cursor to previous edited position tooC-iandC-ojump to previous cursor forward or backwardmato mark position as a and use'ato go to the line where the mark is or`a(backtick) to go to the position of the marked ie.aShift-LandShift-Hmoves cursor to lower (L) or higher (H) screenShift-Mmoves cursor to the middle of the screen- Split windows with Evil shorcut
:spor evil-window-splitC-w sor evil-window-vsplitC-w v. SPC-s dsearch current directory orSpc-s pcurrent projectSPC-'resume last search%move to matching paranthesesSPC-b-lorSPC-`move to last buffer
Editing
In Normal mode:
dbdelete backward till next whitespaced$delete to end of line from cursord0delete to start of line from cursords(delete columns or any parantheses specify aftersie. symbolscwkill from cursor position to next whitespace4cwkill 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.[oand]owill insert newline above or below respectivelyC-jwill cut/split the sentencegUfor UPPERCASE orgulowercase org~to toggle between:eedit file:wsave fileviwselect a word under the cursor*select all word under the cursor in the buffer#select all word in the same line/search wordvioselect 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.ciwchange the inner word under the cursor and move to inner mode.Spc-s ssearch word orfwandFwS-"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-wdelete 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
Rkey, then edit. - Save the file with
C-c C-cor 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
jmultiple times (or5j) to jump by 5 lines, orGto 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
Escis pressed, then all lines will be updated. - Press
Esc.
Search
Different approach to search
Project
SPC SPCfind file in projectSPC s psearch project for textSPC s dsearch files in directory for text
M-x consult-ripgrep
Nice function for flexible search
#alpha betasearch for alpha and beta in any order#alpha.*betasearch for alpha before beta#\(alpha\|beta\)search for alpha or beta#first#secondsearch for first, quick filter for second
Regular expression
- To find unmatched quote using this regex
^[^"]*"[^"]*$
Online search
SPC s osearch onlineSPC s tsearch online dictionary
Org related
SPC-m-hto change to headingSPC-m-ito change to itemShift-TABto move backward in table
Good to know
SPC-h-vorC-h vto check the value or default value of any function.SPC-TAB-TABchange workspaceC-x C-ttranspose lineM-ttranspose 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
+spellthen you need to installhunspell.
sudo apt install hunspell