1
00:00:00,050 --> 00:00:03,010
- [Instructor] Let's open 3.txt.

2
00:00:03,010 --> 00:00:05,060
Vim 3.txt.

3
00:00:05,060 --> 00:00:08,010
Say you're not happy with the header marker, and you would

4
00:00:08,010 --> 00:00:11,050
like to replace it from the equal sign to dash.

5
00:00:11,050 --> 00:00:15,060
Open a new line in Insert mode using O.

6
00:00:15,060 --> 00:00:17,050
Then write the new header.

7
00:00:17,050 --> 00:00:20,030
Dash, dash, dash, dash, dash, dash.

8
00:00:20,030 --> 00:00:23,060
Now you'd like to copy and paste the new header.

9
00:00:23,060 --> 00:00:25,080
We'll first yank the new header,

10
00:00:25,080 --> 00:00:28,050
so back to Normal mode with Escape,

11
00:00:28,050 --> 00:00:32,010
and then Y Y to copy the line.

12
00:00:32,010 --> 00:00:34,090
Now move one line down with J,

13
00:00:34,090 --> 00:00:37,090
and use D D to delete the line.

14
00:00:37,090 --> 00:00:41,030
So next, move to the next header with forward search.

15
00:00:41,030 --> 00:00:45,010
So forward slash, equal sign, Enter.

16
00:00:45,010 --> 00:00:48,070
And now paste the new header with a uppercase P.

17
00:00:48,070 --> 00:00:50,070
So Shift + P.

18
00:00:50,070 --> 00:00:52,010
You got the old header.

19
00:00:52,010 --> 00:00:53,080
What just happened?

20
00:00:53,080 --> 00:00:56,020
When you did D D to delete the line,

21
00:00:56,020 --> 00:00:59,040
it was yanked to same register, or clipboard,

22
00:00:59,040 --> 00:01:00,080
over the new header.

23
00:01:00,080 --> 00:01:02,020
To solve this problem,

24
00:01:02,020 --> 00:01:06,080
Vim provide us with many registers, 52 of them.

25
00:01:06,080 --> 00:01:10,040
All the English letters both lower and uppercase.

26
00:01:10,040 --> 00:01:12,050
Let's get back to our initial state,

27
00:01:12,050 --> 00:01:16,040
by hitting U several times, U U U.

28
00:01:16,040 --> 00:01:18,020
And now we'll do it again.

29
00:01:18,020 --> 00:01:22,050
So, O for Insert mode, the new header,

30
00:01:22,050 --> 00:01:25,050
and then Escape back to Normal mode.

31
00:01:25,050 --> 00:01:28,080
And this time we're going to yank the line to Register A.

32
00:01:28,080 --> 00:01:32,020
To do that, we do double quote A,

33
00:01:32,020 --> 00:01:37,040
and then Y Y for copying the line into Register A.

34
00:01:37,040 --> 00:01:39,080
Now, delete the current header with D D.

35
00:01:39,080 --> 00:01:44,000
So J to move one down and D D to delete the line.

36
00:01:44,000 --> 00:01:45,060
Now we move to the next header

37
00:01:45,060 --> 00:01:50,080
with a forward search, so forward slash, equal sign, Enter.

38
00:01:50,080 --> 00:01:52,070
And now to paste from Register A,

39
00:01:52,070 --> 00:01:57,030
we'll use the same prefix of double quote A,

40
00:01:57,030 --> 00:02:00,080
and then lowercase B, Shift + B.

41
00:02:00,080 --> 00:02:02,070
And now we can delete the old header.

42
00:02:02,070 --> 00:02:07,010
One line down with J, and D D to remove the line.

43
00:02:07,010 --> 00:02:09,010
Let's move to the next header.

44
00:02:09,010 --> 00:02:12,050
Forward slash, equal, Enter.

45
00:02:12,050 --> 00:02:17,020
You can save yet one more keystroke by using G, lowercase P

46
00:02:17,020 --> 00:02:22,030
which will paste the text but move the cursor just below it.

47
00:02:22,030 --> 00:02:24,080
So the prefix for the register,

48
00:02:24,080 --> 00:02:28,070
double quote A, and then G, Shift + B.

49
00:02:28,070 --> 00:02:31,050
And now D D to delete the line.

50
00:02:31,050 --> 00:02:32,070
Once you get used to the fact

51
00:02:32,070 --> 00:02:34,010
that you have many registers,

52
00:02:34,010 --> 00:02:36,000
you'll find many great uses for them.

