Using the VI Editor (For Windows Types)

KB ID 0001304 Dtd 20/04/17

Problem

I dont have a ginger ponytail, nor do I wear sandals, couple these two things together and you will understand why I find VI so confusing! Many times I've had to alter a config file on an appliance, or a Linux box, and sat frowning at VI wondering why I can't change a one to a zero.

Note: Nano is easier, if possible try nano {filename} to save hassle. But on hardened appliances for example, it wont be there. 🙁

So, this article gives you enough information to open, edit, and save a file. If you want a massive tutorial on VI you are in the wrong place.

Solution

Not really part of VI but you need to know where the file is you want to edit, and the path to it;

For Example:

vi {filename}
vi {path}/{filename}

Locate you file to edit in vi

You can 'move around' the file being edited with your arrow keys.

Navigate VI editor

Deleting Text: Press the X key to delete the character that's 'under' the cursor.

003-vi-editor-deleting-text

Selecting Text: Press (and hold) the V Key while using the arrow keys to select multiple text characters.

Selecting Text in VI

Note: From here you can CUT (press X), or COPY (press Y). To PASTE put the cursor where you want the text and press P.

Inserting Text: To actually type anything, you need to be in 'insert' mode press I then type in your text.

Note: Some flavours of Linux give no indication you are in 'insert' mode, (unlike the example below).

Inserting text in Vi

Saving and Exiting: you need to be in 'command' mode to save and exit, to enter 'command' mode press ESC. As above there may be no visual clue what mode you are in. To SAVE AND EXIT type :wq {Enter}. TO EXIT Type :q {Enter}. Basically q means quit and w means 'write' the changes.

Job done, now keep your Linux skills quiet or you may get your dinner money stolen, and not get a girlfriend.

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *