Vim Grammar

Using vim is like talking to your editor in number verb modifier object sentences, turned into acronyms

Number

Enter nonzero number before the command, to repeat the command number times.

Verbs

keyfunctionverb form
v visual selecttransitive
c change, enter insert modetransitive
d deletetransitive
y yank / copytransitive
xdelete charnon-transitive
i insert, enter insert mode, before the cursornon-transitive
a append, enter insert mode, after the cursornon-transitive
p pastenon-transitive
n Nfind next/previous search results of / or ?non-transitive

Modifiers

keyfunction
i inside
a around
t till find a character, not including the character
f find a character, including the character
/search downwards, find a string or regex
?search upwards, find a string or regex

Objects

keyfunction
w word
s sentence
b block / parentheses
p paragraph
t tag, for html/xml tags
G go to the last line
number G go to the number line
g g go to the first line, the same as 1 G
0number 0, to the first character of current line
$to the last character of current line

Examples

Key

key sequence (command mode)function
xdelete the current character
ppaste

Number + Key

key sequence (command mode)function
8 xdelete the next 8 characters
2 jmove down the cursor by 2 lines

Key + Object

key sequence (command mode)function
d wdelete to the end of the (next) word
c wdelete to the end of the (next) word, enter insert mode

Key + Modifier + Object

key sequence (command mode)function
d i wdelete the current word
c i wchange the word, enters insert mode
c i schange current sentence
c i "change inside " "
c i {change inside { }
c / f o ochange until next occurrence of foo
c t 8change everything from here until number 8
c f 8like above, but also remove the number
c a pchange the current paragraph
v a pvisually select this paragraph

Reference Chart

Alt

Open Large Figure

Alt

Open Large Figure

Alt

Open Large Figure

Reference Link

Learn to speak vim — verbs, nouns, and modifiers!

Using "verbs" and "nouns" for text editing

Vi/vim emulation for Visual Studio, SQL Server, Word & Outlook

Linux vi/vim

Categories: CodingComputer

0 Comments

Leave a Reply

Your email address will not be published.