vim commands Flashcards

1
Q

:e filename

A

Open filename for edition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

:w

A

Save file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

:q

A

Exit Vim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

:q!

A

Quit without saving

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

:x

A

Write file (if changes has been made) and exit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

:sav

A

filename Saves file as filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

.

A

Repeats the last change made in normal mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

5.

A

Repeats 5 times the last change made in normal mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

k or Up Arrow

A

move the cursor up one line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

j or Down Arrow

A

move the cursor down one line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

e

A

move the cursor to the end of the word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

b

A

move the cursor to the beginning of the word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

0

A

move the cursor to the beginning of the line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

G

A

move the cursor to the end of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

gg

A

move the cursor to the beginning of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

L

A

move the cursor to the bottom of the screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

:59

A

move cursor to line 59. Replace 59 by the desired line number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

20|

A

move cursor to column 20.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

%

A

Move cursor to matching parenthesis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

[[

A

Jump to function start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

[{

A

Jump to block start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

y

A

Copy the selected text to clipboard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

p

A

Paste clipboard contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

dd

A

Cut current line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

yy

A

Copy current line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

y$

A

Copy to end of line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

D

A

Cut to end of line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

/word

A

Search word from top to bottom

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

?word

A

Search word from bottom to top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

*

A

Search the word under cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

/\cstring

A

Search STRING or string - case insensitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

/jo[ha]n

A

Search john or joan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

/< the

A

Search the or theater or then

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

/the>

A

Search the or breathe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

/< the>

A

Search the

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

/< ¦.>

A

Search all words of 4 letters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

/\/

A

Search fred but not alfred or frederick

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

/fred|joe

A

Search fred or joe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

/\

A

Search exactly 4 digits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

/^\n{3}

A

Find 3 empty lines

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

:bufdo /searchstr/

A

Search in all open files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

bufdo %s/something/somethingelse/g

A

Search something in all the open buffers and replace it with somethingelse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

:%s/old/new/g

A

Replace all occurrences of old by new in file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

:%s/onward/forward/gi

A

Replace onward by forward - case insensitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

:%s/old/new/gc

A

Replace all occurrences with confirmation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

:%s/^/hello/g

A

Replace the beginning of each line by hello

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

:%s/$/Harry/g

A

Replace the end of each line by Harry

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

:%s/onward/forward/gi

A

Replace onward by forward - case insensitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

:%s/ *$//g

A

Delete all white spaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

:g/string/d

A

Delete all lines containing string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

:v/string/d

A

Delete all lines containing which didn’t contain string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

:s/Bill/Steve/

A

Replace the first occurrence of Bill by Steve in current line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

:s/Bill/Steve/g

A

Replace Bill by Steve in current line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

:%s/Bill/Steve/g

A

Replace Bill by Steve in all the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

:%s/^M//g

A

Delete DOS carriage returns (^M)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

:%s/\r/\r/g

A

Transform DOS carriage returns in returns

57
Q

:%s#]+>##g

A

Delete HTML tags but keeps text

58
Q

:%s/^(.*)\n\1$/\1/

A

Delete lines which appears twice

59
Q

Ctrl+a

A

Increment number under the cursor

60
Q

Ctrl+x

A

Decrement number under cursor

61
Q

ggVGg?

A

Change text to Rot13

62
Q

Vu

A

Lowercase line

63
Q

VU

A

Uppercase line

64
Q

g~~

A

Invert case

65
Q

vEU

A

Switch word to uppercase

66
Q

vE~

A

Modify word case

67
Q

ggguG

A

Set all text to lowercase

68
Q

gggUG

A

Set all text to uppercase

69
Q

:set ignorecase

A

Ignore case in searches

70
Q

:set smartcase

A

Ignore case in searches excepted if an uppercase letter is used

71
Q

:%s/<./\u&/g

A

Sets first letter of each word to uppercase

72
Q

:%s/<./\l&/g

A

Sets first letter of each word to lowercase

73
Q

:%s/.*/\u&

A

Sets first letter of each line to uppercase

74
Q

:%s/.*/\l&

A

Sets first letter of each line to lowercase

75
Q

:r infile

A

Insert the content of infile

76
Q

:23r infile

A

Insert the content of infile under line 23

77
Q

:e .

A

Open integrated file explorer

78
Q

:Sex

A

Split window and open integrated file explorer

79
Q

:Sex!

A

Same as :Sex but split window vertically

80
Q

:browse e

A

Graphical file explorer

81
Q

:ls

A

List buffers

82
Q

:cd ..

A

Move to parent directory

83
Q

:args

A

List files

84
Q

:args *.php

A

Open file list with extension .php

85
Q

:grep expression *.php

A

Returns a list of .php files containing expression

86
Q

gf

A

Open file name under cursor

87
Q

:!pwd

A

Execute the pwd unix command then returns to Vi

88
Q

!!pwd

A

Execute the pwd unix command and insert output in file

89
Q

:sh

A

Temporary returns to Unix

90
Q

$exit

A

Returns to Vi

91
Q

%!fmt

A

Align all lines

92
Q

!}fmt

A

Align all lines at the current position

93
Q

5!!fmt

A

Align the next 5 lines

94
Q

:tabnew

A

Creates a new tab

95
Q

gt

A

Show next tab

96
Q

:tabfirst

A

Show first tab

97
Q

:tablast

A

Show last tab

98
Q

:tabm n(position)

A

Rearrange tabs

99
Q

:tabdo %s/foo/bar/g

A

Execute a command in all tabs

100
Q

:tab ball

A

Puts all open files in tabs

101
Q

:new abc.txt

A

Edit abc.txt in new window

102
Q

:e filename

A

Edit filename in current window

103
Q

:split filename

A

Split the window and open filename

104
Q

ctrl-w up arrow

A

Puts cursor in top window

105
Q

ctrl-w ctrl-w

A

Puts cursor in next window

106
Q

ctrl-w_

A

Maximize current window vertically

107
Q

ctrl-w|

A

Maximize current window horizontally

108
Q

ctrl-w=

A

Gives the same size to all windows

109
Q

10 ctrl-w+

A

Add 10 lines to current window

110
Q

:vsplit file

A

Split window vertically

111
Q

:sview file

A

Same as :split in readonly mode

112
Q

:hide

A

Close current window

113
Q

:­nly

A

Close all windows - excepting current

114
Q

:b 2

A

Open #2 in this window

115
Q

Ctrl+n Ctrl+p (in insert mode)

A

Complete word

116
Q

Ctrl+x Ctrl+l

A

Complete line

117
Q

:set dictionary=dict

A

Define dict as a dictionary

118
Q

Ctrl+x Ctrl+k

A

Complete with dictionary

119
Q

m {a-z}

A

Marks current position as {a-z}

120
Q

’ {a-z}

A

Move to position {a-z}

121
Q

’’

A

Move to previous position

122
Q

:ab mail mail@provider.org

A

Define mail as abbreviation of mail@provider.org

123
Q

:set autoindent

A

Turn on auto-indent

124
Q

:set smartindent

A

Turn on intelligent auto-indent

125
Q

:set shiftwidth=4

A

Defines 4 spaces as indent size

126
Q

ctrl-t

A

Indent in insert mode

127
Q

ctrl-d

A

Un-indent in insert mode

128
Q

> >

A

Indent

129
Q

«

A

Un-indent

130
Q

=%

A

Indent the code between parenthesis

131
Q

1GVG=

A

Indent the whole file

132
Q

:syntax on

A

Turn on syntax highlighting

133
Q

:syntax off

A

Turn off syntax highlighting

134
Q

:set syntax=perl

A

Force syntax highlighting

135
Q

:1,10 w outfile

A

Saves lines 1 to 10 in outfile

136
Q

:1,10 w&raquo_space; outfile

A

Appends lines 1 to 10 to outfile

137
Q

:2,35s/old/new/g

A

Replace all occurrences between lines 2 and 35

138
Q

:5,$s/old/new/g

A

Replace all occurrences from line 5 to EOF