1
00:00:00,050 --> 00:00:03,010
- [Instructor] Vim has many great movement commands.

2
00:00:03,010 --> 00:00:05,010
However, sometimes you'd like to see

3
00:00:05,010 --> 00:00:08,020
what is the part of the text you're selecting.

4
00:00:08,020 --> 00:00:11,010
To do this, Vim has a visual mode.

5
00:00:11,010 --> 00:00:13,010
In this mode, you select lines

6
00:00:13,010 --> 00:00:15,080
and Vim will highlight them for you.

7
00:00:15,080 --> 00:00:18,020
Let's open light.txt.

8
00:00:18,020 --> 00:00:21,050
Vim light.txt.

9
00:00:21,050 --> 00:00:25,000
To enter visual mode use shift + v.

10
00:00:25,000 --> 00:00:27,060
You can see the status bar at the bottom

11
00:00:27,060 --> 00:00:30,000
changes to visual line.

12
00:00:30,000 --> 00:00:31,090
Shift + v selected one line.

13
00:00:31,090 --> 00:00:33,080
And now we can extend the selection

14
00:00:33,080 --> 00:00:35,070
using motion commands.

15
00:00:35,070 --> 00:00:41,010
For example, let's use j to select another line.

16
00:00:41,010 --> 00:00:42,080
Once you're happy with the selection

17
00:00:42,080 --> 00:00:44,080
you can decide what to do with it.

18
00:00:44,080 --> 00:00:48,020
Let's delete these two lines with d.

19
00:00:48,020 --> 00:00:49,070
Shift + v selects lines.

20
00:00:49,070 --> 00:00:53,020
You can also use control + v to select blocks.

21
00:00:53,020 --> 00:00:55,090
Let's undo with u.

22
00:00:55,090 --> 00:00:58,060
And now control + v.

23
00:00:58,060 --> 00:01:00,000
You can see the status bar below

24
00:01:00,000 --> 00:01:02,040
changing to visual block.

25
00:01:02,040 --> 00:01:05,060
Extend the block one column to the right, using l.

26
00:01:05,060 --> 00:01:10,010
And now four more lines using four + j.

27
00:01:10,010 --> 00:01:11,070
Once you've selected the block

28
00:01:11,070 --> 00:01:13,040
you can decide what to do.

29
00:01:13,040 --> 00:01:16,070
Let's delete the white space with d.

30
00:01:16,070 --> 00:01:18,000
Very handy.

31
00:01:18,000 --> 00:01:20,090
I don't know many developers who can do that.

32
00:01:20,090 --> 00:01:23,010
And other fun you can have with visual blocks

33
00:01:23,010 --> 00:01:24,070
is to change them.

34
00:01:24,070 --> 00:01:27,020
When you change, the whole block is changed.

35
00:01:27,020 --> 00:01:29,050
Let's undo with u.

36
00:01:29,050 --> 00:01:31,030
And we select again.

37
00:01:31,030 --> 00:01:34,050
Control + v + l + four + j.

38
00:01:34,050 --> 00:01:35,050
And now change.

39
00:01:35,050 --> 00:01:37,070
Changing is done with c.

40
00:01:37,070 --> 00:01:40,090
And then we'll write what we want it to replace.

41
00:01:40,090 --> 00:01:43,030
So let's do dash space.

42
00:01:43,030 --> 00:01:46,000
And now hit escape.

43
00:01:46,000 --> 00:01:48,010
All the lines are changed.

44
00:01:48,010 --> 00:01:49,080
I often use visual mode to select

45
00:01:49,080 --> 00:01:52,060
the exact part of the text I'd like to change.

46
00:01:52,060 --> 00:01:55,000
I hope you'll find it useful, as well.

