• Whatsapp

Editor Vi’s introduction

Vi Editor (vee eye, read vi ai) is a screen-based editor used by many UNIX users. This editor was first developed by William (Bill) Joy when he became a graduate student at the University of California at Berkeley in 1976.

Vi’s editor has many facilities that are very helpful for programmers, but novice users avoid Vi because they consider this editor very difficult and confusing. This chapter is intended to introduce novice users to the Vi editor.

Why Use Vi
Here are some reasons why you use Vi:
– Vi is generally available on every UNIX system, so if you master Vi, it will be easy to do editing tasks on any UNIX system.
– Vi is free, you are free to use it and see the source code.
– Vi can be adjusted to your needs, because the configuration file is available. If you are still not satisfied, maybe you can change the source code according to your needs.
– Vi is much smaller than the Emacs editor.

Vi version
The following is a list of several Vi versions available:

 UnixMS-DOSWindows 3.xWindows 95/98/NT
Elviselvis-2.1_4.tar.gzelvis-2.1_4-msdos.tar.gzNot availableelvis-2.1_4-win32.tar.gz
LemmyNot availableNot availableNot availablelemmy40.exe
Nvinvi-1.79.tar.gzTidak tersediaNot availableNot available
StevieNot availablestevie69x.zip3Not availableNot available
WinViNot availableTidak
XviNot availablexviexe.zipNot
PvicNot availablepvic_dos.zipNot availableaNot available
CalvinNot availablecalvin23.zipNot availableNot available

Before Starting Vi

Vi Editor uses the entire screen, so he needs to know what type of terminal you have. So if one day you can’t start Vi because of the type of terminal that doesn’t match, then you need to change your terminal type.

For example if you have a terminal of type vt100, to change your terminal set in a UNIX shell are as follows:

For C Shell (/ bin / csh), the command is as follows:

set term = vt100

For Bourne Shell (/ bin / sh or / bin / bash) or Korn Shell (/ bin / ksh), the command is as follows:

TERM = vt100 export TERM

Start and End Vi

The Vi editor allows users to create new files or edit existing files. To start Vi from the shell give the command tedi: tedi $ vi If successful, then it will appear
~ VIM – Vi IMproved
~ version 5.4
~ by Bram Moolenaar et al.
~ Vim is freely distributable
~ type: help uganda if you like Vim
~ type: q to exit
~ type: help or for online help
~ type: help version5 for version info

The screen indicates that Vi is ready for use.

You can start the Vi editor without entering a file name, but if you want to save your work, you need to tell Vi the name of your file to save it.

To edit an existing file, the command given is “vi filename”. On the left side of the screen will appear tilde (~). At the bottom of the screen, you will see the name of the file you are editing, and the size of the file, as shown in the following snippet:

Baca Juga:  Handphone Gaming Vivo Ini Super Ngebut Menggunakan MediaTek Dimensity 1000+

“filename” 21 lines, 385 characters

To end Vi, press then type: q

If successful, you will return to the shell.

Direction Navigation in Vi
To move the cursor in the Vi editor, you can use the buttons as follows:

h l


The h button is on the left, to move to the left.
The l button is on the right and to move to the right.
The j button looks like a down arrow

In the new Vi version, these functions can also be done by using the directional buttons found on the keyboard.

In addition there are also several commands for other cursor movements, namely:

g: to move to a certain line.
^ F: move one full screen down.
^ B: move one full screen up.
^ D: move half the screen down.
^ U: move half screen up.
^ w: move one word forward.
^ b: move one word backwards.

The ^ sign is the Ctrl key, ^ F means you have to press the Ctrl key together with the F. key.

Editing Text

Enter Text
To enter text, give the command i (insert) by first switching to command mode (press ESC). At the bottom of the screen a message will appear as follows:


– – INSERT – –

This indicates that Vi is ready to accept the text you will enter. You can then enter the text you want. With the command i, the text to be entered is added before the current cursor position. In addition there is also a command that will add text after the current cursor position. The next two commands that can also be used to enter text are the o and O commands. The command is used to open newline after the current line and add text, while the O command will open newline before the current line and add text.

Deleting Text

There are times when editing, we want to delete a text. In Vi text deletion can be done in several ways including:

Delete characters one by one? Delete one line

To be able to delete characters one by one can be done in the command mode by pressing the button then pressing the x button when the cursor is on the character you want to delete. To be clearer, note the following snippet, here you want to delete the character “a” in the word “normal”.

Initial state:

I’m not ordinary

The state when switching to command mode and giving the x command when the cursor is in the second letter from the end of the line and deletes one character “a”:

I’m not ordinary


Circumference after one character has been deleted:

I can not


Besides the removal of a character can also be done in insert mode by pressing the button. Note the following snippet:

Initial state:

I’m not ordinary



Then move the cursor until the character you want to delete. Then press the button once.

The result is :

I can not

Baca Juga:  Cara membersihkan RAM pada komputer dan laptop


Sometimes it is necessary to delete a line thoroughly, then deleting one line by deleting one character at a time is of course very unpleasant and inefficient, for this purpose Vi provides the dd command.

To be able to run it first we need to enter the command mode then press the dd button. In order to be more honest, note the following snippet:

Here the line that contains the phrase “me too” will be deleted.

I’m not used to me too



The first step to do is to enter the command mode by pressing the button. If it works then at the bottom of the screen there is no longer an inscription – INSERT.

I’m not ordinary

me too


The next step is to place the cursor on the line you want to delete and press the dd button. If successful, the desired row has been deleted.

I’m not ordinary


Cancel command (Undo command)

To cancel the last command can be done by pressing the u button. Meanwhile to cancel all commands press the U key.

Consider the following example:

I’m not used to it

Then we delete the last letter “a” by pressing the x button in command mode. The results are as follows:

I’m not ordinary
However, we still need the text in a condition that has not been fixed. To return the text or in other words to cancel the deletion of one character, it can be done by pressing the u (undo) button in command mode.

The results after cancellation of the command are:

I’m not used to it

Putting Text (Put)

If you want to put the text can be done by first deleting the text, then put it back with the put command, that is by pressing the p button.

Note the following snippet of text:

2 of these two

1 this one

4 of these four

3 of these three
The text is in a non-sequential state, we want to sort the text, the steps are as follows:

– Switch to command mode by pressing the button

– Delete the line that contains text 2 with the dd command

– Place the cursor on the line containing text 1

– Press the p (put) button. The results are as follows:

1 this one

2 of these two

4 of these four

3 of these three

– Place the cursor on the line containing text 4

– Delete the line with dd

– Place the cursor on the line containing text 3

– Press the p button

– Text has been sorted.

The results after being sorted are:

1 this one

2 of these two

3 of these three

4 of these four

Operation on File

Save File

To save the text that you have filled in or have edited, it can be done by moving to command mode and giving the command: w (point two w), after that the text will be saved and you can continue your work.

This command can also be accompanied by other commands, especially the “quit” command, so to save the file and then exit the Vi editor it can be done by giving the command: wq.

Baca Juga:  Tutorial Twibbonize untuk Mengganti Foto Profil Media Sosial

If you haven’t named your file, it can be done by giving the command: w filename.

Open File
To open an existing file can be done by giving the command: e (colon two). The file that is opened will then appear on the screen.

Insert File
To insert a file into the file you are editing, it can be done by giving the command: r NAMEFILE. After giving this command, the NAMEFILE file will be inserted in the file you are editing by following the cursor.

Search for Words / Sentences
Vi Editor has two kinds of searches: character search and word search. For word search, use the command / and? When you give this command, at the bottom of the screen you can enter the word you want to search. The difference between these two commands is that the command / searches forward temporarily? looking backward. This means the command / search from the current cursor to the end of the document, while the command? search from the current cursor until the beginning of the document. The n and N commands are used to repeat searches before in the same or opposite direction. Some characters have special meanings for Vi editors, so they need to be preceded by a “backslash” if you want to be included in the search.

Special characters

^the beginning of the line (at the beginning of the search expression)
.match with single characters
*match empty or more previous characters
$end of line (at the end of the search expression)
[start a set of expressions that are suitable or not suitable. For example: / kak [hee] will match: kaki kaka kake. Is drawn in a diescape expression with backslash to find the end or beginning of a word. Example: / just search for the word de, but not words like: deh and dessy.
>see character

Character searches looking for characters entered after the command. The f and F commands look for characters only on the current line. f searches forward while F searches backward and the cursor moves to the character found. The t and T commands search for characters only on the current line, but for commands t the cursor moves to the position before the character, while T searches backward to the position after the character.

These two sets of commands can be repeated using the command; or, Orders; repeating the last character search command in the same direction, temporarily, repeating the search command in the opposite direction.

Configuring Editor Vi
You can configure your Vi editor when it starts. There are several options that can be set by using the command: set in edit mode. The following are some of the available options (you can get it by typing: set all then press Enter in command mode):


Some of these options have values that can be set with “=” in them, while others are set or not set (this option is an option called Boolean and has “no” in front of it to indicate that they are not set).

An explanation of some of the above commands will be given below, with an abbreviation. For example, the autoindent set command, you can write:: set autoindent or: set ai. To unset it, you can type: set noautoindent or: set noai.

autoindent (ai)this option is used to set the editor so that the line following the selected line will have the same indentation as the previous line. Indent width can be determined by shiftwidth.
exrcthe .exrc file in the current directory will be read at start up. It must be set both in the EXINIT environment variable and in the .exrc file in your home directory.
number (nu)displays a row with the row number to the left.
shiftwidth (sw)this option takes a value and specifies the stop tab width. (The Stop software tab is used for commands >> and
showmode (smd)this option is used to indicate the actual mode you are in. If you are in insert mode, then the bottom of the editor will appear INSERT
warn this option will remind you if you have modified the file but have not saved it
window (wi)this option determines how many lines on the screen Vi uses. For example, to set Vi editor to only use 12 screen lines, use: set wi = 12.
wrapscan (ws)this choice affects word search behavior. If the wrapscan is set, if the word is not found at the bottom of the file, it will be searched at the beginning.
wrapmargin (wm)if this option has more than zero values, the editor will automatically do wordwrap. That is, when you enter a lot of space on the left side of the margin, the word will move to the next line.

Returning Your Work When Unwanted Things happen with your Terminal.
The Vi Editor edits a temporary copy of your file, and after the editing process is complete, or when you save it, he puts the temporary copy into the original file. If something goes wrong when you are editing, Vi’s editor will try to save the existing work, and try to restore it for future rescue. Note: If Vi stops when you are working on any file, it will email you how to return it. -R command stands for recovery. If you are editing the value list file and you are suddenly out, the -r command will be very helpful. The command is as follows vi -r list value. After using -r once, you have to save what you have got. The -r command only works once for each session that fails.

Pos terkait

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *