VIM Hacks
VIM Hacks
code
Description
Category
Mode
Example
Tags
Company
zwmark a good word as misspelled
Spell Checking
zqmark a misspelled word as correct
Spell Checking
z=browse suggestions on a misspelled word
Spell Checking
yt;copy everything from here to the next
;ysiw<em>emphasize the current word (it works with text objects!) Want to know what's crazier about that? It's dot repeatable!.
Surround Actions
ysiw[surround the current word with brackets
Surround Actions
yipcopy (inside) paragraph
yyank (copy)
Verbs
Insert
xexterminate (delete) from character under the cursor
Deleting Text
Normal
exterminate
Xexterminate (delete) the character before the cursor
Deleting Text
Normal
exterminate
wword
Nouns
wmove forward one word
Moving By Word
Wmove forward one big word
Moving By Word
vwwyenter visual mode, select two or more words of text, and copy them
vhack
VS<p class="important”>visually select the line, and surround it with the p tags
Vjjdenter line-based visual mode, delete a couple of lines below
vhack
vipyjjdvisually select an entire paragraph, copy it, then paste it two lines below
vhack
vipvisually select entire paragraph
vhack
vi{select inside curly brackets
vhack
vi(select inside parenthesis
vhack
vi {file}open your file in vim
file
v2i{select everything inside the second tier braces (two levels out of the current nested set)
vhack
vvisually select (V for line vs. character)
Verbs
Normal
venter char-based visual mode
Visual
Venter line-based visual mode
Visual
t<jump forward and land right before the
<tsearches for something and stops before it
Modifiers
Normal
ttag think (HTML/XML)
Nouns
tjump up to a character
search
s {NOUN}substitute from where you are to the next command (noun)
Changing Text
Insert
substitute
ssentence
Nouns
Sselect anything, and then type S. You'll be brought to the bottom of the window. Now type in what you want to wrap that with, such as <a href="/images">, and then press enter.
Surround Actions
Ssubstitute the entire current line
Changing Text
Insert
substitute
rreplace the one character under your cursor
Changing Text
Insert
replace
Rreplace the character under your cursor, and continue typing
Changing Text
Replace
replace
qastart recording a macro named “a”
Macros
qstop recording
Macros
pparagraph
Nouns
pgo anywhere and paste theme
vhack
oopen a new line below the current one
Changing Text
Insert
Oopen. a new line above the current one
Changing Text
Insert
n.go to the next instance and append the same text to that line
ngo to the next instance of the searched word
search
Ngo to the previous instance of the searched word
search
Mmove to the middle of the screen
Moving Within Window
lmove right one line
Basic Motions
Normal
Move Right One Line
Lmove to the bottom of the screen
Moving Within Window
kmove up one line
Basic Motions
Normal
Movie Up One Line
jmove down one line
Basic Motions
Normal
Move Down One Line
Jjoin the current line with the next one (delete what’s in between)
Deleting Text
Normal
exterminate
iwinside word
Combo Objects
itinside tags
Combo Objects
isinside sentence
Combo Objects
ipinside paragraph
Combo Objects
i`inside back ticks
Combo Objects
i{inside curly brackets
Combo Objects
i(inside parenthesis
Combo Objects
i"inside double quotes
Combo Objects
i'inside single quotes
Combo Objects
iinside
Modifiers
Normal
iinsert before the cursor
Changing Text
Insert
insert
hmove left one line
Basic Motions
Normal
Move Left One Line
Hmove to the top of the screen
Moving Within Window
gggo to the top of the file
Moving Within Window
Ggo to the bottom of the file
Moving Within Window
f<jump forward and land on the
< on this linefsearches for that thing and lands on it
Modifiers
Normal
fjump on to a character
search
emove to the end of current word
Moving By Word
dt.delete from where you are to the period
Deleting Text
Normal
exterminate
ds"delete the double quotes around something
Surround Actions
ddpswap position of two lines (next line swaps with current line)
hack
change
dddelete the current line
Deleting Text
Normal
exterminate
d2wdelete two words
d {NOUN}delete whatever you define as a
noun, e.g. a word, or a sentence, or a paragraph.Deleting Text
Normal
exterminate
ddelete
Verbs
Visual
Verbs
Ddelete to the end of the line
Deleting Text
Normal
exterminate
CTRL Yscroll down one line
Moving Within Window
CTRL venter paragraph-based visual mode
Visual
CTRL Umove up half a screen
Moving Within Window
CTRL ojump back to where you were
CTRL ijump to your previous navigation location
CTRL Fmove down a page/screen
Moving Within Window
CTRL Escroll up one line
Moving Within Window
CTRL Dmove down half a screen
Moving Within Window
CTRL Bmove up a page/screen
Moving Within Window
ct<change everything from here to the
<ct?change up to the question mark
Changing Text
Insert
change
cs]{change the square brackets around something to curly brackets
Surround Actions
cs"’for the word you're on, change the surrounding quotes from double to single
Surround Actions
cs'<q> for the word you're on, change the surrounding single quotes to
<q>Surround Actions
cischange inside sentence
c {NOUN}change whatever you define as
NOUN (movement), ie a word, a sentence of a paragraphChanging Text
Insert
change
cchange
Verbs
Normal
Cchange the current line from where you are at
Changing Text
Insert
change
bblock (think programming)
Nouns
bmove back one word
Moving By Word
Bmove back one big word
Moving By Word
awaround word
Combo Objects
ataround tags
Combo Objects
asaround sentence
Combo Objects
aparound paragraph
Combo Objects
a`around back ticks
Combo Objects
a{around curly brackets
Combo Objects
a(around parenthesis
Combo Objects
a"around double quotes
Combo Objects
a'around single quotes
Combo Objects
A {another word}append some text to the end of the line of the searched word
aaround
Modifiers
Normal
aappend after the cursor
Changing Text
Insert
append
Aappend at the end of the line
Changing Text
Insert
A this textappend
0i:j0vG.repeat the last action on every line of the file
vhack
&repeat the last exterminate command
Deleting Text
Normal
exterminate
/{word}search for a word
search
/find a string (literal or regex)
Modifiers
Command
*search for other instances of the word under your cursor
search
@aplay back the macro
Macros
}paragraph (another way of doing it)
Nouns
]sgo to next misspelled word
Spell Checking
[sgo to last misspelled word
Spell Checking
)sentence (another way of doing it)
Nouns
’stoggle spelling visuals
Spell Checking
’ffix spelling
Spell Checking
:zzwrite your changes and exit vim
Command
file
:wqwrite your changes and exit vim
Command
file
:wwrite your changes to the file
file
:saveas {~/path}save your file to that location
Command
file
:s /foo/bar/gchange “foo” to “bar” on the current line
hack
replace
:q!get out of vim (quit) without saving changes
Command
file
:${NUMBER}Hmove to a given line number
Moving Within Window
Command
:%s/s+$//delete Ctrl-M white spaces from the end of all files
hack
:%s /foo/bar/gchange “foo” to “bar” on every line
hack
replace
;go to the next instance when you’ve jumped to a character
search
,go to the previous instance when you’ve jumped to a character
search
