Time
8 hours 30 minutes
Difficulty
Beginner
CEU/CPE
10

Video Transcription

00:03
now for our last section in this module. 103.8, the V I editor
00:09
now VI I is important to know about,
00:14
mainly because it's a very powerful editor,
00:16
but also because it's
00:19
pretty much the default editor. You could expect to find out any version of UNIX or lyrics, so we need to know how it works because you can't count on easier to use editors always being available, things like Leave pad or
00:32
other other tools.
00:34
So the navigation with the eyes done with the H J K Nell Keys.
00:39
And if you put if you know how to type touch type. If you move your hand over one letter to the right. Sorry,
00:46
one letter to the left. Your right hand moved one letter to left. Then you'll rest on those four keys, and you can get pretty used to the up and down with Agent J and K, now left and right.
00:58
If you're a touch typing, this should be a fairly easy here, uh,
01:02
adjustment to make.
01:03
I can also go to the beginning of the end of line by using shifted six or shifted for.
01:10
You'll notice there's a consistency here between these carrot being the beginning of the line character and the dollar sign being the end of the line character.
01:18
And I've got W to move to the next word B for the previous word,
01:22
each of the current word and then some other commands using the shift key
01:27
shift l puts me at the bottom of the screen. My cursor there
01:32
I can use Shift H ago, the top of the screen, so that's your high and low.
01:37
And then shift G sends me to the last line. The file
01:41
and I can also specify a specific line file, which we saw earlier when we're looking at some of the grip commands with the dash end.
01:49
If I knew I wanted get tow line 327 I could just type that in and go directly to that line number.
01:57
So let's have a look at V I,
02:05
and I'll go back to Miami
02:07
Messages
02:10
far
02:19
messages, not text.
02:23
So I've got plenty of material to work with. You'll notice when I go into V. I tells me at the bottom how many lines are in this file and how many characters it contains,
02:34
so I get some of that information right from the beginning.
02:39
No,
02:40
um
02:43
I'm hitting the Jakey, moving my cursor down
02:47
the k g, moving the cursor up,
02:51
and then
02:52
l moves it to the right and
02:53
age moves into the left after Look at the keyboard cause I'm so used to doing this without looking.
02:59
But this is very much like the arrow keys. In fact, the arrow keys usually work in V. I have switched to the arrow keys.
03:06
A lot of people might like that better. But once you know the
03:10
the character of the curse of movement, it's not so bad.
03:15
I can
03:15
type the dollar sign and go to the end of the line. A carrot symbol. I go the beginning of the line.
03:22
They're simple stuff.
03:23
The W command
03:24
lose me from one word to the next, and a word is some continuous string of characters. So if it's text, it'll be continuous text a ring. If it's a special character, like an angle bracket or square bracket.
03:37
Now I'm on a new word. I go to the next special character on the next word, and you can see how that works
03:43
be goes in the other direction.
03:45
So I'm getting be to go to the previous word.
03:50
And if I my cursor was here and I want to go to the end of the current word, I can have the e character
03:55
puts me at the end.
03:57
So these were kind of useful.
03:59
Be able to navigate within the file and, uh,
04:03
jumped to the beginning than the line. So they're having to deal with moving the curse around me. Annually
04:08
shift L, as we saw earlier,
04:11
puts me at the bottom of the current screen down there in the lower left corner,
04:16
whereas Shift H puts me at the top of the current screen
04:21
and shift G puts me at the end of the file at the very last line.
04:30
Now, as I mentioned earlier, I could go to a particular line number. So I
04:32
let's say I want to go to lying Number 327. I just tied 3 to 7,
04:38
Then type shift G, and it puts me at that line number.
04:42
I can't really tell because I don't see it within the file itself.
04:46
So let's like some
04:50
review some of the other commands for the different modes,
04:55
then we'll go back and explore some more options.
04:59
So there's two modes. There's the command mode and editing mode
05:03
or insert mode,
05:05
and by default, when you when you added a file, you are in command boat. I have to engage in certain mode by typing a or some other character
05:14
to, uh,
05:15
go into that mode. And then I escaped to get back out of that mode to get back into command mode.
05:23
You'll see here on the table that commands
05:26
allow me to do all of my moving around copying and pasting.
05:30
And then when I've inserted data, Aiken use various commands within the insert mode to do things like,
05:38
uh,
05:40
copying, pasting, adding at the end of the line,
05:43
uh, opening lines above and below, where I'm where my cursor is.
05:47
This gives me a lot of flexibility for how I want to use the editor,
05:54
but I also have to know how to save file. So
05:57
if I hit the
05:59
shift in the semi colon key, I get the colon that you'll see that you'll open up a little cursor at the bottom of the window.
06:05
Here, I can write the founding
06:08
so I can just do Colin W Space founding,
06:12
and this saves my current file as some other name.
06:15
If I want to quit without
06:17
saving any changes, I can do a colon. Q.
06:21
If no changes remain, it will let me exit Changes have been made. I'll get a message. So I have to do que exclamation point or Q bang. In order to abandon those changes,
06:32
I can add it multiple files at one time with envy. I which is Khan Vice
06:36
s so I can quit all of them at the same time by doing the colon que es
06:42
uh, colon w Q rights and quits the current file
06:46
What can actually be replicated with Shift's easy, which is actually faster because the shift in the Z K right next to each other
06:54
I can even revert to a previous
06:56
version of my file by using the Colon, E
07:00
and the bang.
07:00
Let's explore a few of these options.
07:05
All right,
07:08
so
07:09
I'm gonna quit
07:11
and make sure that was editing the correct file.
07:15
So V I gives me, uh, my helper v I You could also use them, which gives you you can use behind a visual mode rather, which gives you some additional
07:27
features to make life a little bit easier.
07:30
Uh, but we can see there's a few other items I can use behind easy mode with Dash y. You might like that
07:36
if you're new to V I. A lot of people complain that the eye is difficult to learn,
07:41
but once you get started with it and start playing around, it becomes second nature very quickly.
07:49
I can also look at some different
07:54
options for launching V. I like,
07:57
uh,
07:58
running a certain command before loading a file. I could break out of the shell and run a command separately, but let's go back and edit that password file.
08:09
Also not password messages that she passwords file. It's Don't do that one
08:18
Now. If I wanted to
08:20
insert some texture, obviously you're not gonna edit password directly. That's usually not the way you would
08:26
would modify this file, but it's a good one for illustrating these things,
08:31
So I know I've got a sequel. Databases command here somewhere
08:35
or log in somewhere. So I'm gonna do slash for a search just type sequel,
08:39
and it finds the my sequel line,
08:43
and I could hit end to go to the next result of that search that's toddling between the two that knows about
08:50
Maybe this, uh, home directory is no longer correct, so I can hit the ikey
08:56
and
08:58
put in some text. So my sequel, Dash Home might be the name of the directory,
09:03
just as an example now had escaped to go back to command mode, I can navigate the file as before
09:11
I can hit you to undo, which is nice.
09:13
I'll put that back in there,
09:16
escape again.
09:18
And once I'm in the
09:22
the file
09:24
for adding or deleting text,
09:26
I can hit the ex key to delete one character at a time.
09:31
I'll insert that again to put some more text.
09:33
I can also
09:35
pity uh,
09:37
the Deke Command and the W Command for delete word.
09:41
So I deleted whatever text was between my cursor and the next delimit ER, which is
09:46
a coal. In this case,
09:50
I can also delete an entire line, and I can copy and paste lines, which will see here in a little bit.
09:58
For instance, let's say I want to
10:03
open a line above the line that I'm on Aiken type shift oak that opens a new line. It puts me in to insert mode.
10:11
It escaped to get out of that mode.
10:13
Uh, D d
10:16
the D for delete body for two days together deletes the line
10:20
so I can delete an entire line.
10:22
I can also do a copy and paste so I can tie. Why? Why? For Yank
10:28
and P for put. And now I've just duplicated that line.
10:33
I could also do something a little more tricky. I can put numbers in front of these things, So if I want to delete five lines, I can take the number five D D. Now I've just got rid of five lines.
10:43
I can also yank five lines. So five. Why? Why
10:46
tells me at the bottom five lines yet. And I can hit P to pace those
10:50
lines that I just copied.
10:54
So it's hard to see this when you're looking at the editor because you don't really see what's going on behind the scenes. But if you
11:00
practice with the commands, find yourself a good V. I cheat cheat. There's plenty of those available
11:07
that show you the
11:09
some of the shortcuts. For all the commands that I've been trying to show here
11:13
I could also do other things like Shift A puts me at the end of line, puts me into insert mode
11:20
shift. Oh, whoops. Not shift. Oh, sorry about that. It's the wrong character to use
11:26
shift. I go to the end of line first dollar sign
11:31
shift I puts me at the beginning of the line, puts me and insert mode.
11:39
So these air nice little short cuts that you can get used to when you're using the editor more frequently,
11:46
you can also go into visual mode,
11:50
which allows you to select a text
11:52
more like you would with a mouse.
11:54
And that could be useful when you're trying to. Uh,
11:58
um,
12:01
do do you copy and pasting operations and a little bit more of a
12:05
a familiar way.
12:07
I personally don't like visual motive. I'm already used to the normal mode.
12:13
Now the zero character puts me at the beginning of the line,
12:16
uh,
12:18
as well so I can get there
12:22
without having to curse her over and deal with that extra extra work.
12:31
So these are some of the commands I was just reviewing.
12:35
So in starting to left, the cursor inserting at the beginning of the liner at the end of the line, inserting text above or below
12:43
opens below shift opens above.
12:46
If I'm if I'm copying text with the Yank Command,
12:50
I can, uh,
12:52
use Why Why do you think the lines above my cursor?
12:56
Why? To link yank lines below my cursor and then peed to pace the lines below the cursor and shifted Peter paste above.
13:03
So when I'm using shift, I'm I'm either yanking or putting above. But I'm using the wire, the p by themselves. I'm yanking below or putting below.
13:13
And then we shot. We saw the you command for undoing changes
13:18
so the eyes are very powerful. But again, it's a bit of a learning curve,
13:24
so get familiar with the navigation. Get familiar with the copy, pasting, deleting and navigating at the word level or at the line level, and you'll be in great shape for the exam.
13:35
And I try not to rely on other editors. If you can enforce yourself to stick with the eye until you've mastered it, it'll pay off in the end.
13:41
All right, that gets us to the end of module 103 So our next module is one of four, which is, uh, file systems and the file system hierarchy standard.
13:50
See you then. Thank you.

Up Next

CompTIA Linux+

Our self-paced online CompTIA Linux+ course prepares students with the knowledge to become a certified Linux+ expert, spanning a curriculum that covers Linux maintenance tasks, user assistance and installation and configuration.

Instructed By

Instructor Profile Image
Dean Pompilio
CEO of SteppingStone Solutions
Instructor