Skip to content

Instantly share code, notes, and snippets.

@dhh
Created September 15, 2024 02:38
Show Gist options
  • Save dhh/038234d3bdf89c40480566a2cb5ba2fd to your computer and use it in GitHub Desktop.
Save dhh/038234d3bdf89c40480566a2cb5ba2fd to your computer and use it in GitHub Desktop.

Vim Manipulation Cheat Sheet

Action

Key Result
v select
y copy (yank)
c change
d delete

Scope

Key Result
a around
i inside

Object

Key Result
w word
p paragraph
s sentence
q quotes
b brackets
o block
t tag
i indention level
W white space

Examples

Command Result
vaq select around current word
yiW copy between last and next white space
ciq change inside quotes
dii delete everything at current indention

Extra

Command Result
f<char> find next character, stop on it
t<char> find next character, stop before it
F<char> find prev character, stop on it
T<char> find prev character, stop before it
Command Result
ct" change from cursor to next " (leaving ")
df| delete from cursor to next | (including |)
@kjvdven
Copy link

kjvdven commented Sep 15, 2024

Nice, add it to my notes!

And some of mine:

# decrease a number
ctrl + a

# increase a number
ctrl + x
# yank and paste with registers
" + 0 + y
" + 0 + p
# Search and replace complete file
:%s/cat/dog/gc

# Lijn 2 t/m 10
:2,10s/cat/dog/g

# Huidige lijn tot einde
:.,$s/cat/dog/g

# Huidige lijn + 10
:.,+10/cat/dog/g
# Changes the case of current character
~

# Change current line from upper to lower.
guu 

# Change current LINE from lower to upper.
gUU  

# Change to end of current WORD from upper to lower.
guw 

# Invert case to current WORD
g~w

@ayoubsousali
Copy link

Nice work on the cheat sheet! I’ve got a post on my Neovim & tmux key maps, along with plugins like Telescope and nvim-tree. Feel free to check it out: Link to the post
Maybe it will help someone.

@feketegy
Copy link

feketegy commented Sep 17, 2024

@ayoubsousali nice list. I noticed this section, there is a simpler way of doing this: yiw to yank the word then viwp to paste over the second word. v enter select mode iw select inside the word, finally p to put the yanked word.

I have viwp set as a shortcut with <leader>+p

image

@ayoubsousali
Copy link

@feketegy yeah your method is simpler, and i like the +p shortcut it's very handy

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