vim basics Flashcards

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
Q

How to remove the whole word and then get the insert mode to place correct word instead?

A

ce

26
Q

What is c?

A

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
Q

What is the format for c operator?

A

c [number] motion

c5e kills 5 words

28
Q

How to display current location in the file and the file status?

A

ctrl + G

29
Q

How to move to the end of the file?

A

G (shift + g)

30
Q

How to move to the line with it’s exact number?

A

[number] G

503G - moves you to the 503 line

31
Q

Move to the first line

A

gg

or 1G

32
Q

How to search in the file?

A

/

like /cat

33
Q

How to jump to the next occurrence in the search results?

A

n

34
Q

How to search for the previous occurrence in the opposite direction

A

N

35
Q

How to search in the file starting in the backward direction?

A

?

like ?cat

36
Q

How to get back to starting position where you came from after trip on search results? How to go forward then?

A

ctrl + O - go back

ctrl + I - go forward

37
Q

Inside of () {} [] parenthesis which key jumps cursor to the beginning and then after second key hit to the end of the block?

A

%

38
Q

Substitute old pattern found in the current line with the new word

A

:s/pattern/new

39
Q

Substitute every occurence of pattern between two lines

A

:1,10s/pattern/new/g

1 and 10 are line numbers

40
Q

How to change every occurrence in the whole file.

A

:%s/old/new/g

41
Q

How to find every occurrence in the whole file with a prompt call whether to substitute or not.

A

:%s/old/new/gc

42
Q

How to run system shell commands from the vim?

A

:!
e.g.:
:!pwd
:!ls

43
Q

How to higlight text for visual selection?

A

v

v starts visual selection mode and then you can use motion keys to move selection cursor

44
Q

How to select and then save part of the file to other new file?

A

v :w FILENAME

45
Q

How to insert the whole text from the external file?

A

: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
Q

How to save shell’s output below the cursor in the current file?

A

:r !
e.g.: :r !ls
which reads the output of the ls command and puts it below the cursor.

47
Q

How to create a line BELOW the cursor and start insert mode?

A

o

48
Q

How to create a line ABOVE the cursor and start insert mode?

A

O

49
Q

How to start insert mode AFTER the cursor?

A

a

50
Q

How to enter Replace mode and what is it?

A

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
Q

How to copy text?

A

v [motions] y
vwy - yanks (copies) one word
v$y - copies the whole line starting from cursor position

52
Q

How to paste text from the vim buffer?

A

p

doesn’t work if you want to paste text from external programs

53
Q

How to paste text from the external programs?

A

Shift + Insert

54
Q

How to ignore case during the /search ?

A

:set ic

55
Q

How to bring back default setting when case is important for the search operations?

A

:set noic

56
Q

How to highlight in color every search match?

A

:set hls is

sets the hlsearch (highlighted search) and incsearch

57
Q

How to ignore case for just one search command?

A

/\c

58
Q

How to split vim window in two halves to open some second another file?

A

Ctrl + N

59
Q

How to switch between two opened files?

A

Ctrl + W

60
Q

How to call help for the command?

A

:help command_name

61
Q

How to select text, delete it and then put it in some other place inside current file?

A

v [your_motions_to_select]
d
[your_navigaton_to_the_neded_place]
p