Skip to content

Instantly share code, notes, and snippets.

@ashton314
Last active October 9, 2021 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashton314/4b313f1322acf8df3d5f723c33279c86 to your computer and use it in GitHub Desktop.
Save ashton314/4b313f1322acf8df3d5f723c33279c86 to your computer and use it in GitHub Desktop.

Learning Evil Mode

Resources

This guy’s tutorials look pretty excellent:

An Emacs Addict’s Guide to Evil-Mode

Window Management

C-x {2,3}
C-w s / :sp, C-w v / :vsp
C-x o
C-w {h,j,k,l}
C-x 1
C-w o

Buffer/file management

C-x C-f
:e <filename>
C-x b
:ls
C-x 0
:q

Mark, Kill, Yank, etc.

  • Hit v to toggle “visual mode” to start selecting text
    • While in Visual mode, you can hit o to exchange point and mark
C-w
d (works with visual mode turned on)
M-w
y (ditto; this is called “yank”)
C-y
p (“put”)

Query Search/Replace

Replace this pattern with that string: :s/this pattern/that string/gc

The c flag on the end signals that vim should confirm replacements, much like query-replace in Emacs.

Misc. Tips

C-o
(While in insert mode) switch to normal mode for the next command.
xp
Simulates swapping a character, by first deleting it, then putting it back.
dawwP
Simulates swapping a word, by first deleting it, moving forward, then putting it behind the current character.
V
(shift-v) visual mode, but start by selecting the current line
C-v
visual-block mode, like C-x C-SPC
C-r
redo, but I need to customize my unto system first
f<char>
move to a character before your cursor; think avy-goto-char-1
F<char>
same, but backwards
t<char>
move to the char before the one specified; ditto with T<char>
<num>G
Goto line <num>
D
Same as Ctrl-k in Emacs
df(
Delete up to the next (
cf(
Ditto, but leave in insert mode (like the change commands)

Cursor Control

zz
Like hitting C-l to center a line
z<RET>
Put current line at top
z-
Put current line at bottom
z.
Does something similar

Global Shortcuts

gf
edit filename under cursor
gx
call open on the file under cursor
gi
go to last edit and set cursor to insert mode
g;
go to next change
=g,=
go to previous change
gi
I think this means “go to last edit and insert”
gt, gT
go forward, back tabs

Macros:

q<letter>
start recording macro in register <letter>
q
stop recording
@<letter>
replay macro

Window-fu: (leader for all these is C-w)

s
split horizontally
v
split vertically
n
split horizontally and edit a new file
r
rotate windows
x
swap with next window
===
resize all windows to be equal (like C-x = in Emacs-mode)
-, +
decrease, increase height
<, >
decrease, increase width

Text/prose editing things

(, )
go to the beginning and end of a sentance
z=
run ispell-word
\\==
(two equal signs) indent current line

Unimpaired

[<SPC>, ]<SPC>
insert spaces above and below

Surround

From Normal Mode

yS<open delimiter><movement>
wrap the movement (e.g., for w wrap a word, f. will wrap to the next period) in the delimiter with space padding
yS<close delimiter><movement>
same as above, but don’t put spaces around the delimiters

From Visual Mode

Similar to From Normal Mode, but it doesn’t take a movement. Instead, just wraps whatever you’ve marked. This might be easier to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment