1
00:00:00,050 --> 00:00:01,080
- [Instructor] It's very common to work

2
00:00:01,080 --> 00:00:04,000
on more than one file at a time.

3
00:00:04,000 --> 00:00:06,070
Vim supports editing multiple files as well.

4
00:00:06,070 --> 00:00:09,050
But you need to understand the terminology of it.

5
00:00:09,050 --> 00:00:13,030
A buffer is the content of the file being edited.

6
00:00:13,030 --> 00:00:15,010
It can be a new file, or a file

7
00:00:15,010 --> 00:00:17,040
that's already exists on disk.

8
00:00:17,040 --> 00:00:19,050
All the changes you are doing to a buffer

9
00:00:19,050 --> 00:00:23,020
will only be written to disk if you save the buffer.

10
00:00:23,020 --> 00:00:26,090
A window is a view to a buffer.

11
00:00:26,090 --> 00:00:28,000
You can have several windows pointing

12
00:00:28,000 --> 00:00:31,010
to the same buffer in different places.

13
00:00:31,010 --> 00:00:32,080
Let's have a look.

14
00:00:32,080 --> 00:00:36,030
Vim perfect.txt.

15
00:00:36,030 --> 00:00:43,040
Now open a new window to the same buffer with :split.

16
00:00:43,040 --> 00:00:47,000
Say you'd like to add where the first quote came from.

17
00:00:47,000 --> 00:00:53,060
Find the location with /P enter

18
00:00:53,060 --> 00:00:57,000
and move to the end of the file with dollar

19
00:00:57,000 --> 00:01:00,000
and enter insert mode with "a".

20
00:01:00,000 --> 00:01:01,060
And now write.

21
00:01:01,060 --> 00:01:03,060
And this quote is from

22
00:01:03,060 --> 00:01:07,040
Zen and the Art of Motorcycle Maintenance.

23
00:01:07,040 --> 00:01:11,040
As you can see, the bottom window is updated as well.

24
00:01:11,040 --> 00:01:13,090
Let's move to the end of the current window.

25
00:01:13,090 --> 00:01:17,040
Escape and then Shift + G.

26
00:01:17,040 --> 00:01:20,090
As you can see the bottom window did not change.

27
00:01:20,090 --> 00:01:24,010
You can move between windows with Control + W

28
00:01:24,010 --> 00:01:25,040
and then an action.

29
00:01:25,040 --> 00:01:27,050
For example, to move to the next window,

30
00:01:27,050 --> 00:01:30,080
use Control + W W.

31
00:01:30,080 --> 00:01:33,030
And if you do Control + W W again

32
00:01:33,030 --> 00:01:36,000
it will cycle between the windows.

33
00:01:36,000 --> 00:01:40,040
To close a window, do a Control + W and C.

34
00:01:40,040 --> 00:01:43,010
You can do much more with windows

35
00:01:43,010 --> 00:01:45,010
including resizes, moving and more.

36
00:01:45,010 --> 00:01:48,030
I personally prefer to work with a single window at a time.

37
00:01:48,030 --> 00:01:50,030
But in some cases, such as viewing

38
00:01:50,030 --> 00:01:54,000
differences between two files, it can be very handy.

