vim commands Flashcards

(138 cards)

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
yy
Copy current line
26
y$
Copy to end of line
27
D
Cut to end of line
28
/word
Search word from top to bottom
29
?word
Search word from bottom to top
30
*
Search the word under cursor
31
/\cstring
Search STRING or string - case insensitive
32
/jo[ha]n
Search john or joan
33
/\< the
Search the or theater or then
34
/the\>
Search the or breathe
35
/\< the\>
Search the
36
/\< ¦.\>
Search all words of 4 letters
37
/\/
Search fred but not alfred or frederick
38
/fred\|joe
Search fred or joe
39
/\
Search exactly 4 digits
40
/^\n\{3}
Find 3 empty lines
41
:bufdo /searchstr/
Search in all open files
42
bufdo %s/something/somethingelse/g
Search something in all the open buffers and replace it with somethingelse
43
:%s/old/new/g
Replace all occurrences of old by new in file
44
:%s/onward/forward/gi
Replace onward by forward - case insensitive
45
:%s/old/new/gc
Replace all occurrences with confirmation
46
:%s/^/hello/g
Replace the beginning of each line by hello
47
:%s/$/Harry/g
Replace the end of each line by Harry
48
:%s/onward/forward/gi
Replace onward by forward - case insensitive
49
:%s/ *$//g
Delete all white spaces
50
:g/string/d
Delete all lines containing string
51
:v/string/d
Delete all lines containing which didn’t contain string
52
:s/Bill/Steve/
Replace the first occurrence of Bill by Steve in current line
53
:s/Bill/Steve/g
Replace Bill by Steve in current line
54
:%s/Bill/Steve/g
Replace Bill by Steve in all the file
55
:%s/^M//g
Delete DOS carriage returns (^M)
56
:%s/\r/\r/g
Transform DOS carriage returns in returns
57
:%s#]\+>##g
Delete HTML tags but keeps text
58
:%s/^\(.*\)\n\1$/\1/
Delete lines which appears twice
59
Ctrl+a
Increment number under the cursor
60
Ctrl+x
Decrement number under cursor
61
ggVGg?
Change text to Rot13
62
Vu
Lowercase line
63
VU
Uppercase line
64
g~~
Invert case
65
vEU
Switch word to uppercase
66
vE~
Modify word case
67
ggguG
Set all text to lowercase
68
gggUG
Set all text to uppercase
69
:set ignorecase
Ignore case in searches
70
:set smartcase
Ignore case in searches excepted if an uppercase letter is used
71
:%s/\<./\u&/g
Sets first letter of each word to uppercase
72
:%s/\<./\l&/g
Sets first letter of each word to lowercase
73
:%s/.*/\u&
Sets first letter of each line to uppercase
74
:%s/.*/\l&
Sets first letter of each line to lowercase
75
:r infile
Insert the content of infile
76
:23r infile
Insert the content of infile under line 23
77
:e .
Open integrated file explorer
78
:Sex
Split window and open integrated file explorer
79
:Sex!
Same as :Sex but split window vertically
80
:browse e
Graphical file explorer
81
:ls
List buffers
82
:cd ..
Move to parent directory
83
:args
List files
84
:args *.php
Open file list with extension .php
85
:grep expression *.php
Returns a list of .php files containing expression
86
gf
Open file name under cursor
87
:!pwd
Execute the pwd unix command then returns to Vi
88
!!pwd
Execute the pwd unix command and insert output in file
89
:sh
Temporary returns to Unix
90
$exit
Returns to Vi
91
%!fmt
Align all lines
92
!}fmt
Align all lines at the current position
93
5!!fmt
Align the next 5 lines
94
:tabnew
Creates a new tab
95
gt
Show next tab
96
:tabfirst
Show first tab
97
:tablast
Show last tab
98
:tabm n(position)
Rearrange tabs
99
:tabdo %s/foo/bar/g
Execute a command in all tabs
100
:tab ball
Puts all open files in tabs
101
:new abc.txt
Edit abc.txt in new window
102
:e filename
Edit filename in current window
103
:split filename
Split the window and open filename
104
ctrl-w up arrow
Puts cursor in top window
105
ctrl-w ctrl-w
Puts cursor in next window
106
ctrl-w_
Maximize current window vertically
107
ctrl-w|
Maximize current window horizontally
108
ctrl-w=
Gives the same size to all windows
109
10 ctrl-w+
Add 10 lines to current window
110
:vsplit file
Split window vertically
111
:sview file
Same as :split in readonly mode
112
:hide
Close current window
113
:­nly
Close all windows - excepting current
114
:b 2
Open #2 in this window
115
Ctrl+n Ctrl+p (in insert mode)
Complete word
116
Ctrl+x Ctrl+l
Complete line
117
:set dictionary=dict
Define dict as a dictionary
118
Ctrl+x Ctrl+k
Complete with dictionary
119
m {a-z}
Marks current position as {a-z}
120
' {a-z}
Move to position {a-z}
121
''
Move to previous position
122
:ab mail mail@provider.org
Define mail as abbreviation of mail@provider.org
123
:set autoindent
Turn on auto-indent
124
:set smartindent
Turn on intelligent auto-indent
125
:set shiftwidth=4
Defines 4 spaces as indent size
126
ctrl-t
Indent in insert mode
127
ctrl-d
Un-indent in insert mode
128
>>
Indent
129
<<
Un-indent
130
=%
Indent the code between parenthesis
131
1GVG=
Indent the whole file
132
:syntax on
Turn on syntax highlighting
133
:syntax off
Turn off syntax highlighting
134
:set syntax=perl
Force syntax highlighting
135
:1,10 w outfile
Saves lines 1 to 10 in outfile
136
:1,10 w >> outfile
Appends lines 1 to 10 to outfile
137
:2,35s/old/new/g
Replace all occurrences between lines 2 and 35
138
:5,$s/old/new/g
Replace all occurrences from line 5 to EOF