1
00:00:00,050 --> 00:00:01,070
- [Instructor] Ken Thompson said,

2
00:00:01,070 --> 00:00:03,060
"One of my most productive days

3
00:00:03,060 --> 00:00:06,060
"was throwing away a thousand lines of code."

4
00:00:06,060 --> 00:00:08,030
Deleting text is an important part

5
00:00:08,030 --> 00:00:10,090
of writing, and Vim makes it easy.

6
00:00:10,090 --> 00:00:13,030
Can you guess the command for deleting text?

7
00:00:13,030 --> 00:00:14,080
It's d.

8
00:00:14,080 --> 00:00:17,010
Let's open persistence.txt,

9
00:00:17,010 --> 00:00:19,080
vim persistence.txt.

10
00:00:19,080 --> 00:00:22,030
And now to delete, type d.

11
00:00:22,030 --> 00:00:23,020
Nothing happens.

12
00:00:23,020 --> 00:00:26,040
The d command needs to know what to delete.

13
00:00:26,040 --> 00:00:28,090
Now type w.

14
00:00:28,090 --> 00:00:30,080
And the first word was deleted.

15
00:00:30,080 --> 00:00:34,020
dw stands for delete word.

16
00:00:34,020 --> 00:00:36,040
To undo, hit u.

17
00:00:36,040 --> 00:00:38,030
Now let's delete a sentence.

18
00:00:38,030 --> 00:00:40,060
Remember that the sentence motion

19
00:00:40,060 --> 00:00:45,040
is the closing braces, so d and closing braces.

20
00:00:45,040 --> 00:00:47,090
And again, u to undo.

21
00:00:47,090 --> 00:00:52,000
To delete a line, use dd.

22
00:00:52,000 --> 00:00:54,020
And again, u to undo.

23
00:00:54,020 --> 00:00:57,030
We can even use regular expression motion to delete.

24
00:00:57,030 --> 00:01:00,040
Let's delete everything up to genius.

25
00:01:00,040 --> 00:01:07,030
So, d and then /Genius and enter.

26
00:01:07,030 --> 00:01:09,020
Remember that d is for delete,

27
00:01:09,020 --> 00:01:13,030
and it should be followed by a motion command, such as w.

28
00:01:13,030 --> 00:01:16,000
To delete the current line, use dd.

