1
00:00:00,870 --> 00:00:06,150
I'm adding this lecture after I recorded the rest of the lectures for this section of the course, just

2
00:00:06,150 --> 00:00:12,600
because it occurred to me that I keep editing files on the remote server using a tool called Vij, some

3
00:00:12,600 --> 00:00:13,500
people call it vem.

4
00:00:13,500 --> 00:00:14,460
I call it Vij.

5
00:00:14,910 --> 00:00:16,590
And you may not be that familiar with it.

6
00:00:16,590 --> 00:00:22,470
And I'm not sure that I gave enough instructions to actually enable you to use it usefully.

7
00:00:23,010 --> 00:00:26,730
So this is just a short lecture that gives you a crash course in VI.

8
00:00:27,240 --> 00:00:28,560
So I'm going to connect to the server.

9
00:00:29,820 --> 00:00:31,080
So I'm connecting.

10
00:00:32,770 --> 00:00:35,830
And I'll clear the screen and I'm in my home directory.

11
00:00:35,860 --> 00:00:36,350
OK?

12
00:00:36,730 --> 00:00:40,960
And I just saw that by typing TWD for print working directory.

13
00:00:41,350 --> 00:00:48,640
And if I want to say go up a level, I can dot dot to go up on level and last list the files and I'll

14
00:00:48,640 --> 00:00:50,320
go back into TC's.

15
00:00:50,380 --> 00:00:53,590
OK, so inside of that I have two files.

16
00:00:53,590 --> 00:00:56,050
I want to create a new file which I'm going to call test.

17
00:00:56,060 --> 00:01:03,880
I'll create that by typing the command VI and then test text because it's a text file and that opens

18
00:01:03,880 --> 00:01:10,780
the VI editor and the VI editor is incredibly powerful and I'm not going to go anywhere near through

19
00:01:10,780 --> 00:01:14,720
all of the commands that are available to you, but I'll give you enough that you'll be able to do things.

20
00:01:15,220 --> 00:01:21,550
So when this is first opened, if I want to be able to insert some text, I'll type the letter.

21
00:01:21,610 --> 00:01:24,460
I actually I think I hit to know there.

22
00:01:24,640 --> 00:01:29,020
But anyway, I and that you notice in the bottom right and the left hand corner, it now says you're

23
00:01:29,020 --> 00:01:34,750
an insert mode and I can, I can type things now I have a typo there.

24
00:01:34,780 --> 00:01:41,500
If I want to get rid of that and change that wi to an H like it should be, I have to hit escape.

25
00:01:41,710 --> 00:01:47,050
That gets me out of edit or the insert mode and then I'll use the arrow keys to get over top of that.

26
00:01:47,380 --> 00:01:55,870
I'll type the letter X to delete that X I to reinsert and I will change it to an H and now I can go

27
00:01:55,870 --> 00:01:56,770
back to the end of this.

28
00:01:57,070 --> 00:02:04,600
I can type things and now I can type more and again I'll get out of in certain mode by hitting the escape

29
00:02:04,600 --> 00:02:04,950
key.

30
00:02:06,160 --> 00:02:08,110
Now that I've done this, I want to save it.

31
00:02:08,260 --> 00:02:14,320
So I'm going to type a colon shift and then the shift semicolon, which is the colon key that brings

32
00:02:14,320 --> 00:02:15,370
up the command.

33
00:02:15,370 --> 00:02:19,510
And in the bottom left hand corner, you'll see it's now a colon and I'll type W four.

34
00:02:19,510 --> 00:02:19,930
Right.

35
00:02:20,380 --> 00:02:21,640
And that writes the file.

36
00:02:21,820 --> 00:02:25,150
And if I want to get out of here again, I'm not in insert mode.

37
00:02:25,150 --> 00:02:26,500
And if I am, I would hit escape.

38
00:02:26,830 --> 00:02:30,520
I'll hit the colon again to bring up the command and I'll take a cue.

39
00:02:31,210 --> 00:02:32,410
And now I'm quite out of it.

40
00:02:32,500 --> 00:02:38,920
And if I clear the screen and type ls to list the contents of this directory, there is my test text

41
00:02:38,920 --> 00:02:43,300
file and if I type cat to actually print this out, the contents of it.

42
00:02:43,580 --> 00:02:46,510
Test, test, text.

43
00:02:46,750 --> 00:02:48,100
There's the file that I typed.

44
00:02:48,640 --> 00:02:54,340
If I want to edit that file down Vij test text and it brings it back up.

45
00:02:54,850 --> 00:02:56,650
Now let's say I want to have a new line here.

46
00:02:56,650 --> 00:03:03,670
I could hit I and then press return or I can just type O which will insert a new line and put me in

47
00:03:03,670 --> 00:03:11,500
a certain mode and now I am in insert mode period hit escape to get out of it.

48
00:03:11,710 --> 00:03:18,820
Colden to bring up the command a bit wq I can do the right and quit as one command and we're good.

49
00:03:19,900 --> 00:03:20,920
Let's do it again.

50
00:03:21,550 --> 00:03:24,490
Let's say I want to get rid of this entire line.

51
00:03:24,520 --> 00:03:27,670
I can type D and that will delete the entire line.

52
00:03:27,670 --> 00:03:36,610
I can delete this line to D and get back and insert mode and type some new text.

53
00:03:37,390 --> 00:03:45,040
Now I'm going to get out of insert mode and I'm going to go y y to copy y y copies the current line

54
00:03:45,370 --> 00:03:48,850
and then P to paste and Peter paste and Peter paste and Peter paste.

55
00:03:49,180 --> 00:03:55,270
And I'm going to go up to this middle line and I'm going to delete the words sum by hitting X four times

56
00:03:55,270 --> 00:03:58,270
X X, X, X I again.

57
00:03:58,270 --> 00:04:00,310
And now I'm going to type a word that is unique.

58
00:04:00,310 --> 00:04:04,540
It exists nowhere else in this file and I will call this Treva.

59
00:04:05,140 --> 00:04:11,980
OK, I'll get out of insert mode, bring up my command by typing the colon and now I want to look for

60
00:04:11,980 --> 00:04:13,060
the word Treva.

61
00:04:13,300 --> 00:04:16,120
So I put a slash and Treva and it's case sensitive.

62
00:04:16,120 --> 00:04:19,630
So I had to use the capital T and it will say, hey, there's the line.

63
00:04:19,960 --> 00:04:22,060
It takes me right to the line that has that word.

64
00:04:22,270 --> 00:04:29,880
And if I hit N for next, it jumps right to the word Trevor and I could delete that and put in OK,

65
00:04:30,130 --> 00:04:31,060
I've got the wrong spot.

66
00:04:32,140 --> 00:04:38,170
Mary escape colon WQ to save and quit and we're done.

67
00:04:38,170 --> 00:04:40,660
And that is our crash course in VI.

68
00:04:41,020 --> 00:04:45,130
Now I've added to the resources for this page a cheat sheet for VI.

69
00:04:45,370 --> 00:04:47,380
And if you don't like VI, there are other editors.

70
00:04:47,380 --> 00:04:53,020
I think there's one called Pekoe, which I never used peacoat test text and that brings up something

71
00:04:53,020 --> 00:04:55,270
that actually might be more useful for you.

72
00:04:55,510 --> 00:04:57,760
So this might be a little friendlier for you.

73
00:04:57,760 --> 00:04:58,630
I don't like it.

74
00:04:58,630 --> 00:05:00,850
I find VI extremely easy to use.

75
00:05:00,850 --> 00:05:06,130
You have to learn basically three or four basic commands how to get into the insert mode with an eye.

76
00:05:06,340 --> 00:05:12,070
The escape gets you to your command of the insert mode and typing a colon brings you into the command

77
00:05:12,310 --> 00:05:13,810
bit where you can save and quit.

78
00:05:14,110 --> 00:05:16,480
And that's sufficient for our purposes, for this course.

79
00:05:16,480 --> 00:05:21,670
But if you want to learn how to use Nano, just Google it and all the instructions will be there.

80
00:05:21,760 --> 00:05:28,960
I want to exit right now and it looks like Control X gets me out control X and we're OK.

81
00:05:28,990 --> 00:05:29,680
So that does it.

82
00:05:30,070 --> 00:05:31,990
But it's is really easy to use in.

83
00:05:32,040 --> 00:05:33,500
I strongly encourage you to learn it.

84
00:05:33,510 --> 00:05:37,980
It will make your life much easier when you're managing configuration files on a server.
