VIM Flashcards
VIM word vs WORD
word: hello , . [
WORD:
hello(){}
hello(2,3)
[1, 2, 3, 4]
Jump to the end of a word backwards
ge - word
gE - WORD
Move just before the character (until)
t/T{char}
! Delete everything before the “(“
Repeaters
;/, - f & t
n/N - / and ?
Go to the first character of the line
0 (zero)
Go to the first non-blank character of the line
Go to the end of the line
$
Go to the last non-blank character of the line
g_
Jump the entire paragraph downwards
}
Jump the entire paragraph upwards
{
Move down half a page by scrolling page
CTRL-D
Move up half a page by scrolling page
CTRL-U
Search backwards
?
Repeat the last search
/[enter] or ?[enter]
Search the word under your cursor
* - forward # - backwards
Go to definition of the thing under the cursor
gd
Go to a file in import
gf
Go to the top of a file
gg
Go to the end of a file
G
Jump to maching ({[]})
%
Operator
An action to preform (Delete, Put, Change, Yank…)
Count
A multiplier to perform action X times
Motion
The piece of text to which to apply the action defined by the operator (word, WORD, line…)
Combining operators and motions
{operator}{count}{motion}
{motion}{count}{operator}
delete 2 WORDS
d2W
delete 3 lines downwards
d3j
delete everything in the current line until the ‘ character, including the ‘ character
df’
delete everything in the current line until the ( character, excluding the ( character
dt(
delete everything until the first occurrence of hello (excluding hello)
d/hello
delete the entire contents of a document
ggdG
c
Change
deletes a piece of text and then sends you into insert mode. Like d and i combined
switch case
g~
make something lowercase
gu
make something uppercase
gU
shift right (add indentation)
>
shift left (remove indentation)
format code
=
copy a whole document
ggyG
capitalise a world
gUw
change whole line
cc
delete to the end of the line
D
change to the end of the line
C
paste before the cursor
P
VIM: What is a document composed of?
Of text objects:
- words
- sentences
- quoted text
- paragraphs
- blocks
- (HTML) tags