1
00:00:00,050 --> 00:00:02,090
- [Instructor] Say you're writing some Python code,

2
00:00:02,090 --> 00:00:05,080
vim hello.py.

3
00:00:05,080 --> 00:00:09,040
You decided to license your code under the Apache license.

4
00:00:09,040 --> 00:00:12,020
I need to add a header to every file.

5
00:00:12,020 --> 00:00:15,050
An easy solution is to write such a header

6
00:00:15,050 --> 00:00:17,080
and then read it into a file.

7
00:00:17,080 --> 00:00:21,070
To read the file, use :r.

8
00:00:21,070 --> 00:00:25,080
Since :r inserts the text under the current line,

9
00:00:25,080 --> 00:00:28,060
we first need to insert a new line.

10
00:00:28,060 --> 00:00:32,010
So, Shift + o and then escape

11
00:00:32,010 --> 00:00:39,090
and then :r and license header.txt and end.

12
00:00:39,090 --> 00:00:42,030
And now the delete the new line.

13
00:00:42,030 --> 00:00:46,080
So, K to move one line up and DD to remove the line.

14
00:00:46,080 --> 00:00:50,020
You can make it simpler if you use a motion command.

15
00:00:50,020 --> 00:00:53,030
We can use the minus one line, the previous line,

16
00:00:53,030 --> 00:00:56,010
as the location to insert the new line.

17
00:00:56,010 --> 00:01:00,050
Let's undo with :e! and enter.

18
00:01:00,050 --> 00:01:03,040
This will reload the file from the disk

19
00:01:03,040 --> 00:01:06,060
disregarding any changes we made to it.

20
00:01:06,060 --> 00:01:11,030
And now, :-1 and then read

21
00:01:11,030 --> 00:01:17,020
and then license header.txt and enter.

22
00:01:17,020 --> 00:01:19,080
If you start to find imperfects and hit Tab

23
00:01:19,080 --> 00:01:21,090
vim will complete the name for you.

24
00:01:21,090 --> 00:01:29,000
So, :-1r li and tab and we got the file name.

