-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvim-notes
More file actions
135 lines (101 loc) · 4.84 KB
/
Copy pathvim-notes
File metadata and controls
135 lines (101 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
terminologyAuthor: Nazim Leulmi , EKA Ryan
Course: Vim Master Class
Prof: Jason Cannon
~=> Module #0 ~ Vim Quick Start <=~
1. The concept of modes :-
~ Normal-mode :-
~> You are in this mode by default.
~> This is also known as the command mode.
~> Case sensetive commands.
~ Insert-mode :-
~> Access this mode by pressing "i".
~> Leave the mode by pressing "ESC" or escape.
~> The text you write is inserted into the buffer.
~ Cmdline-mode :-
~> Issue/Execute commands by pressing ":".
~> Execute pattern search commands by pressing "?"|"/".
~> Execute the filter command by pressing "!"
~> Abondon the command by pressing "ESC".
- Some other variations of the main modes
2. Basic cmdline commands :-
:q! ~> Quit without saving.
:wq ~> Write changes & quit.
"!" ~> Ignore everything and force execute the command.
"." ~> Repeat the previous command.
~=> Module #1 ~ Vim Essentials <=~
1. Essential navigation commands
"k" ~> Move up a line | up arrow.
"l" ~> Move one letter to the right | right arrow.
"h" ~> Move one letter to the left | left arrow.
"w" ~> Move one word to the right including punctuation.
"W" ~> Move one word to the right ignoring punctuation.
"b" ~> Move one word to the left including punctuation.
"B" ~> Move one word to the left ignoring punctuation.
"0" ~> Move to the beginning of the line.
"$" ~> Move to the end of the line.
n"gg" ~> Move to the (n)'th line | it defaults to the first line.
n"G" ~> Move to the (n)'th line | it defaults to the last line.
ctrl-f ~> Page down | forward.
ctrl-b ~> Page up | backward.
2. Deleting commands & thinking in vim :-
"X" ~> Delete a char before the cursor position.
"x" ~> Delete a char at the cursor position.
"dd" ~> Delete the whole line.
- Pattern : operation{motion}
"dw" ~> Delete a word on the left of the cursor .
"db" ~> Delete a word on the right left of the cursor .
- Pattern : {count}operation{motion}
n"w" ~> Move (n) words to the right.
n"dw" ~> Delete (n) words on the right of the cursor.
n"dd" ~> Delete (n) lines.
- Pattern : {count}operation{count}{motion}
"d3w" ~> Delete 3 words on the right of the cursor.
~> this is equal to 3dw.
"2d3w"~> Delete 3 words on the right twice.
~> this is equal to 6dw.
3. Accessing the vim manual eka help system :-
":h|:help"
~> Open the vim manual in read-only mode.
":h :command"
~> Open the manual and look for a specific command.
"Ctrl-d"
~> Show all auto-completion choices.
"tab"
~> Loop through the auto-completion choices.
"Ctrl-ww"
~> Switch the cursor between the manual and your file.
4. Deleting Yanking and Putting :-
~ Vim terminology :-
- Delete ~> Cut
- Put ~> Paste
- Yank ~> Copy
- Register ~> Clipboard like storage used to store and retrieve text.
~ There are 3 types of registers in vim :-
- Unnamed ("")
- Contains text from the most recent yank/delete operation .
- Known also as the default register because it covers most of the use cases.
- Numbered ("1 - "9)
- Register "0 contains text from the most recent yank operation.
- Register "1 contains text from the most recent delete/change operation.
- With each delete/yank operation vim shifts the text through the register.
- Named ("a - "z)
~> Full control on what goes on in each named register.
~> Append to a register using an upper case letter of the same register.
~ Examples :-
dd,d & x
~> Delete the text and save it in "" unnamed & "1 numbered register.
dw ~> Delete a word on the right of the cursor and save it in "" unnamed & "1 numbered reg.
p ~> Put the word on the right of the cursor.
P ~> Put the word on the left of the cursor.
yy ~> Yank the whole line.
p ~> Put the whole line below the cursor.
P ~> Put the whole line above the cursor.
~ Vim [count]motion patterns work with yanking, putting and deleting.
"3yy" ~> Yank 3 lines. "4yw" ~> Yank 4 words.
"5dd" ~> Delete 5 lines. "6dw" ~> Delete 6 words.
6. Text Objects & Macros :-
- Text Objects are used after an operation/operator.
- Pattern : {operator}{a|i}{object}
~ "daw" ~> Delete a word & the white space after it.
~ "ciw" ~> Change inner word leaving the delimiter which is a space.
~ "das" ~> Delete a whole sentence including the delimiter.