1
00:00:00,050 --> 00:00:02,080
- When you invoke Vim with an argument starting

2
00:00:02,080 --> 00:00:05,060
with plus sign Vim will interpret this

3
00:00:05,060 --> 00:00:08,060
argument as a command to execute.

4
00:00:08,060 --> 00:00:12,020
A common case is to start Vim in a specific line.

5
00:00:12,020 --> 00:00:16,070
So we do Vim hello.go + 8.

6
00:00:16,070 --> 00:00:19,070
And Vim will start at line number 8.

7
00:00:19,070 --> 00:00:24,060
This is like opening hello.go and then entering colon 8.

8
00:00:24,060 --> 00:00:28,010
Let's quit, colon Q, enter.

9
00:00:28,010 --> 00:00:31,040
However, commands are not limited to just line numbers.

10
00:00:31,040 --> 00:00:33,040
Say you're reading Sherlock Homes story

11
00:00:33,040 --> 00:00:36,030
and you'd like to resume, you remember that you stop

12
00:00:36,030 --> 00:00:40,040
when Count Kramm first came to visit Sherlock.

13
00:00:40,040 --> 00:00:43,010
What we can do is, let's clear the screen,

14
00:00:43,010 --> 00:00:47,020
vim sherlock.txt and then +.

15
00:00:47,020 --> 00:00:50,030
And then we're looking for Kramm

16
00:00:50,030 --> 00:00:52,040
and it will jump to the first occurrence

17
00:00:52,040 --> 00:00:54,080
when Kramm is in the text.

18
00:00:54,080 --> 00:00:57,030
You can specify several commands to

19
00:00:57,030 --> 00:01:00,000
automate some text processing with Vim.

20
00:01:00,000 --> 00:01:05,050
Let's quit this one and clear and have a look

21
00:01:05,050 --> 00:01:07,090
at a file called conway.txt.

22
00:01:07,090 --> 00:01:11,020
We see we have two empty lines at the beginning.

23
00:01:11,020 --> 00:01:15,070
So we can do Vim + 1, 2, which is the range from

24
00:01:15,070 --> 00:01:20,050
line 1 to line 2 and d, the action to delete.

25
00:01:20,050 --> 00:01:24,040
And then another command which is write and quit

26
00:01:24,040 --> 00:01:27,020
and then conway.txt.

27
00:01:27,020 --> 00:01:29,090
And now when we look at conway.txt again

28
00:01:29,090 --> 00:01:33,000
we see that the first two empty lines are gone.

29
00:01:33,000 --> 00:01:35,020
Using press commands you can automate a lot

30
00:01:35,020 --> 00:01:38,000
of text processing tasks with Vim.

