-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathduane.kata
278 lines (229 loc) · 4.62 KB
/
duane.kata
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# Vim Practice
# by Duane Johnson
Use 'j' to move down.
Use 'k' to move up.
Open the following fold: (move to the line and press 'l', or 'za' to toggle)
# Here is the fold {{{1
1. This folds over 4 lines
2. Line 2
3. Line 3
4. Line 4
#}}}
#{{{ Answer:
> :set fdm=manual<Cr>
> Vjzf
#}}}
Create a manual fold:
1. Two-line fold
2. Second line
#{{{ Answer:
> zkzk
#}}}
Navigate to the previous fold, and then to the one before that.
#{{{ Answer:
> mm
#}}}
Mark this line.
#{{{ Answer:
> gg
#}}}
Move to the top of the file, then return to the mark.
#{{{ Answer:
> G
#}}}
Move to the bottom of the file, then return to the mark.
#{{{ Answer:
> H
#}}}
Move the cursor to the top of the window.
#{{{ Answer:
> L
#}}}
Move the cursor to the bottom of the window.
#{{{ Answer:
> M
#}}}
Move the cursor to the middle of the window.
#{{{ Answer:
> C-O
#}}}
Go back to previous jump (i.e. bottom of the window, top of window, bottom of the file, etc.), then go forward to this.
#{{{ Answer:
> qqI--<Esc>lwwi--<Esc>jq@q@@
#}}}
Using a macro recording, prefix the first and third words of each
line with a double dash ("--"):
one two three four
five six seven eight
nine ten eleven twelve
#{{{ Answer:
> "qp
#}}}
Display the contents of the register where you recorded the macro:
#{{{ Answer:
> :s/-/_/g
> "qy
#}}}
Modify the above macro to use underscores instead of dashes, and
then read the macro back into the register.
#{{{ Answer:
> V4j?
#}}}
Using the NERD Comment plugin, toggle comment these lines:
test {
this {
line
}
}
#{{{ Answer:
> gv
#}}}
Restore the Visual Mode selection that you just used above.
#{{{ Answer:
> wds'
#}}}
Using the 'surround' plugin, remove the single quotes.
'surround'
#{{{ Answer:
> wds)
#}}}
Remove parentheses:
(this is a parenthetical statement)
#{{{ Answer:
> C-T
#}}}
Remove tags:
<b>Word</b>
#{{{ Answer:
> f_xves'vEs]
#}}}
Using 'surround', remove the _value and replace with ['value']:
config_value
#{{{ Answer:
> fxvf3s)
#}}}
Add parentheses around the x == 3:
if x == 3 {
}
#{{{ Answer:
> VjS{
#}}}
Surround the above two lines in curly braces.
#{{{ Answer:
> :reg
#}}}
Show the contents of all registers.
#{{{ Answer:
> "ayy
#}}}
Yank the following line into register 'a':
A line for register 'a'.
#{{{ Answer:
> "Ayy
#}}}
Append the following line to register 'a':
Now register 'a' has two lines.
#{{{ Answer:
> "ap
#}}}
Put the two lines in register 'a' below:
#{{{ Answer:
> wwdw
#}}}
Delete the middle word:
Fabulous Text Editing
#{{{ Answer:
> dd
#}}}
Delete this line:
You have a job to do.
#{{{ Answer:
> dd
#}}}
And this one:
Now show how capable you are!
#{{{ Answer:
> "2p
#}}}
Put the 'You have a job to do' line below, using the register for "two deletes ago":
#{{{ Answer:
> "-p
#}}}
Put the word 'Text' below, using the register for "small deletes":
#{{{ Answer:
> f|C
#}}}
Change the text from the | mark to the end of the line:
This is a sent|ence with stuff that needs to change.
#{{{ Answer:
> C-T
#}}}
In Insert Mode, shift the following line right by 2 tab widths:
I feel too left
#{{{ Answer:
> C-D
#}}}
In Insert Mode, shift the following line LEFT by 2 tab widths:
I feel too right
#{{{ Answer:
> word C-O w word
#}}}
In Insert Mode, add a word at the | mark, then use a temporary Normal Mode command to skip a word, then insert another word:
Feel free to |insert a word.
#{{{ Answer:
> C-U
#}}}
In Insert Mode, delete everything before the |:
If you add |words, please clean up after you're done
#{{{ Answer:
> \sbear<Cr>
#}}}
Replace the word 'tiger' with 'bear' in the following three lines:
The tiger lived in the jungle.
There were no other tigers like this tiger.
Tigers are dangerous.
#{{{ Answer:
> :g/\#/d
#}}}
Highlight the following lines and delete those that contain hash symbols:
# Comment
This is text
# Another comment
Some more text
#{{{ Answer:
> :v/\#/d
#}}}
Undo the changes, and remove lines that DO NOT contain hash symbols
#{{{ Answer:
> V4j:g/^/m'<
#}}}
Reverse the following lines:
1. First line
2. Second line
3. Third line
4. Fourth line
#{{{ Answer:
> mm
> (select 4 lines)
> :g//t'm
#}}}
Mark the following line, then select the above 4 lines and copy them to the mark:
Mark this line.
#{{{ Answer:
> :hide e other.txt
#}}}
Edit another file in this window, but don't save the changes you've made to this file.
#{{{ Answer:
> \f
#}}}
Open the NERD Explorer as a vertical split window.
#{{{ Answer:
> s
#}}}
Choose a file in the Explorer and then open it in a new vertical split window.
#{{{ Answer:
> :h
> CTRL-W_H
#}}}
Open a help window, then rearrange as a vertical split.
# vim:foldmethod=marker