1
00:00:00,000 --> 00:00:01,050
- [Instructor] A lot of times,

2
00:00:01,050 --> 00:00:04,000
you'll see where you'd like to be in the text.

3
00:00:04,000 --> 00:00:07,080
In other editors you'd leave the keyboard and use the mouse.

4
00:00:07,080 --> 00:00:10,070
In Vim you have many other ways to navigate to the text

5
00:00:10,070 --> 00:00:13,060
that doesn't require taking your hands off the keyboard.

6
00:00:13,060 --> 00:00:16,040
One that I use a lot is regular expressions.

7
00:00:16,040 --> 00:00:21,000
Let's open sherlock.txt, vim sherlock.txt.

8
00:00:21,000 --> 00:00:23,050
Say you'd like to move to the word trained,

9
00:00:23,050 --> 00:00:26,010
which is in line 11.

10
00:00:26,010 --> 00:00:28,030
If you know how many lines and words you need to move,

11
00:00:28,030 --> 00:00:30,010
you can use these motions.

12
00:00:30,010 --> 00:00:32,060
But an easier way is to search.

13
00:00:32,060 --> 00:00:35,030
Make sure you are in normal mode by hitting Escape,

14
00:00:35,030 --> 00:00:37,050
or Control + C if you don't have Escape.

15
00:00:37,050 --> 00:00:42,070
And then type /tra, and then Enter.

16
00:00:42,070 --> 00:00:45,000
And we see that we are right where we want to.

17
00:00:45,000 --> 00:00:47,040
You can use more than words for searching,

18
00:00:47,040 --> 00:00:50,000
you can use regular expressions.

19
00:00:50,000 --> 00:00:52,070
A regular expression is a way to match text,

20
00:00:52,070 --> 00:00:55,020
and it's beyond the scope of this video.

21
00:00:55,020 --> 00:00:57,010
There are many resources out there

22
00:00:57,010 --> 00:01:00,000
about regular expressions that you can read.

23
00:01:00,000 --> 00:01:02,060
Check out our Learning Regular Expressions course

24
00:01:02,060 --> 00:01:04,040
for more information.

25
00:01:04,040 --> 00:01:07,060
For example, say you're looking for the word chamber,

26
00:01:07,060 --> 00:01:09,060
but you're not sure how it's spelled.

27
00:01:09,060 --> 00:01:12,050
Is there an A, or an E after the CH?

28
00:01:12,050 --> 00:01:14,040
Doesn't matter, use a dot

29
00:01:14,040 --> 00:01:17,060
which is the regular expression for any character.

30
00:01:17,060 --> 00:01:24,000
So /ch.mb, and Enter.

31
00:01:24,000 --> 00:01:25,090
And now we're right on the chamber.

32
00:01:25,090 --> 00:01:28,040
If you'd like to repeat the last search again,

33
00:01:28,040 --> 00:01:32,090
you don't have to type it, just press N for next.

34
00:01:32,090 --> 00:01:34,070
And we're on chamber again.

35
00:01:34,070 --> 00:01:36,020
The forward slash command

36
00:01:36,020 --> 00:01:38,090
searches forward from where you are.

37
00:01:38,090 --> 00:01:42,090
If you'd like to search backwards, use question mark.

38
00:01:42,090 --> 00:01:45,090
For example, ?walk,

39
00:01:45,090 --> 00:01:50,020
and I'm back to walks before where I was.

40
00:01:50,020 --> 00:01:53,030
I move around a lot using regular expressions,

41
00:01:53,030 --> 00:01:54,080
I'm sure that with a bit of practice

42
00:01:54,080 --> 00:01:56,000
you'll find them useful as well.

