vim basics Flashcards

(61 cards)

1
Q

How to append text to the EOL (end of line)

A

A (shift + a)

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

How to quit without saving?

A

:q!

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

How to save edits and quit?

A

:wq

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

How to delete one character like using Del button?

A

x

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

How to delete word and spaces until the start of the next word (cursor is standing on the beginning) ?

A

dw

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

Delete all chars to the end of line

A

d$

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

What is a proper format for a delete command with the d operator?

A
d [number] 
short list of motions: 
w - until the start of the next word, 
e - to the end of the current word, 
$ - to the end of the line
h, j, k, l - right down up left
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens in case you hit motion key ‘w’?

A

A w operator will move cursor until the start of the next word.

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

What happens in case you hit motion key ‘e’?

A

A e (end) operator will move cursor to the end of the current word.

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

What happens in case you hit motion key ‘$’?

A

A $ operator will move cursor to the end of the line.

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

How to move cursor two words forward?

A

2w

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

How to move cursor to the end of the third word forward?

A

3e

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

How to move 50 strings down?

A

50j

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

What are main navigation keys?

A

h - left
j - down
k - up
l - right

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

How to move to the start of the line?

A

0 (zero)

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

How to delete two words?

A

d2w

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

How to delete the whole line (everything to the left and right of the cursor)?

A

dd

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

Kill 2 lines of text

A

2dd

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

How to undo (like ctrl+z)?

A

u

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

How to undo all changes on a line?

A

U (shift + u)

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

Is it possible to undo the undo’s?

A

ctrl + R

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

How to put previously deleted text after current position of the cursor?

A

p

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

Replace a char

A

r

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

Replace a char and put instead of it new character

A

r
like
rn
will delete previous char and put ‘n’ instead of it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How to remove the whole word and then get the insert mode to place correct word instead?
ce
26
What is c?
c is called as change operator. It works in the same way as delete. The only difference against d is that c removes and gives you insert mode immediately. d only removes.
27
What is the format for c operator?
c [number] motion | c5e kills 5 words
28
How to display current location in the file and the file status?
ctrl + G
29
How to move to the end of the file?
G (shift + g)
30
How to move to the line with it's exact number?
[number] G | 503G - moves you to the 503 line
31
Move to the first line
gg | or 1G
32
How to search in the file?
/ | like /cat
33
How to jump to the next occurrence in the search results?
n
34
How to search for the previous occurrence in the opposite direction
N
35
How to search in the file starting in the backward direction?
? | like ?cat
36
How to get back to starting position where you came from after trip on search results? How to go forward then?
ctrl + O - go back | ctrl + I - go forward
37
Inside of () {} [] parenthesis which key jumps cursor to the beginning and then after second key hit to the end of the block?
%
38
Substitute old pattern found in the current line with the new word
:s/pattern/new
39
Substitute every occurence of pattern between two lines
:1,10s/pattern/new/g | 1 and 10 are line numbers
40
How to change every occurrence in the whole file.
:%s/old/new/g
41
How to find every occurrence in the whole file with a prompt call whether to substitute or not.
:%s/old/new/gc
42
How to run system shell commands from the vim?
:! e.g.: :!pwd :!ls
43
How to higlight text for visual selection?
v | v starts visual selection mode and then you can use motion keys to move selection cursor
44
How to select and then save part of the file to other new file?
v :w FILENAME
45
How to insert the whole text from the external file?
:r FILENAME Place cursor in needed point, then :r FILENAME to retrieve the whole text from the file and immediately insert it into your current working file in your cursor position.
46
How to save shell's output below the cursor in the current file?
:r ! e.g.: :r !ls which reads the output of the ls command and puts it below the cursor.
47
How to create a line BELOW the cursor and start insert mode?
o
48
How to create a line ABOVE the cursor and start insert mode?
O
49
How to start insert mode AFTER the cursor?
a
50
How to enter Replace mode and what is it?
R R enters Replace mode until is pressed (so you can replace words instantly - when you type some character it will remove current and move your cursor forward (it's like when in windows you hit the Insert key on the board))
51
How to copy text?
v [motions] y vwy - yanks (copies) one word v$y - copies the whole line starting from cursor position
52
How to paste text from the vim buffer?
p | doesn't work if you want to paste text from external programs
53
How to paste text from the external programs?
Shift + Insert
54
How to ignore case during the /search ?
:set ic
55
How to bring back default setting when case is important for the search operations?
:set noic
56
How to highlight in color every search match?
:set hls is | sets the hlsearch (highlighted search) and incsearch
57
How to ignore case for just one search command?
/\c
58
How to split vim window in two halves to open some second another file?
Ctrl + N
59
How to switch between two opened files?
Ctrl + W
60
How to call help for the command?
:help command_name
61
How to select text, delete it and then put it in some other place inside current file?
v [your_motions_to_select] d [your_navigaton_to_the_neded_place] p