0% found this document useful (0 votes)
8 views6 pages

3.1 02 - Using The Vim Editor

Vim, short for 'Vi Improved', is a widely used text editor in the Linux family, known for its availability across distributions and user-friendliness. It operates in two modes: Command mode for executing commands and Insert mode for text input, with various commands available for editing and navigation. Users can save and close files using specific commands while ensuring they are in Command mode.

Uploaded by

gmsgeemail2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

3.1 02 - Using The Vim Editor

Vim, short for 'Vi Improved', is a widely used text editor in the Linux family, known for its availability across distributions and user-friendliness. It operates in two modes: Command mode for executing commands and Insert mode for text input, with various commands available for editing and navigation. Users can save and close files using specific commands while ensuring they are in Command mode.

Uploaded by

gmsgeemail2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Using the Vim editor

Vim stands for "Vi Improved".


The “vi editor” is the most popular and classic text editor in the Linux
family.
Some of the reasons which make the “vi editor” a widely used editor
is that:
-It is available in almost all Linux distributions.
-It works the same across different platforms and distributions.
-It is user-friendly.
There are advanced versions of the “vi editor” available and the most
popular one is “Vim” which is “Vi Improved”.
It is wise to learn “Vim” because it is feature-rich and offers endless
possibilities to edit a file.
In order to work on “Vim”, you need to understand its operation
modes. They are Two modes:

First, the “Command mode”:


The “Vim” editor opens in this mode and it only understands
commands.
In this mode, you can move the cursor and cut, copy, paste the text.
This mode also saves the changes you have made to the file.
Note that, commands are case sensitive, therefore you should use
the right letter case.

Second, the “Insert mode”:


This mode is for inserting text into the file.
You can switch to the Insert mode from the command mode by
pressing “I” on the keyboard.
Once you are in the Insert mode, any key would be taken as an input
for the file on which you are currently working.
To return to the command mode and save the changes you have
made you need to press the “Esc” key.

Basic commands:
First, moving through the text:
Moving through the text is usually possible with the arrow keys. If
not, try:
“H” to move the cursor to the left.
“I” to move it to the right.
“K” to move up.
“J” to move down.
“Shift+G” will put the prompt at the end of the document.

Starting the vi editor:


To launch the VI Editor -Open the Terminal (CLI “Command Line
Interface”) and type:

vi <filename_NEW> or <filename_EXISTING>

(Don’t forget to leave space between “vi” and “the filename”).


If you specify an existing file then the editor would open it for you to
edit. Else, you will create a new file.

Let's take some of the most used “Vi” Editing commands:


Note that, you should be in the "command mode" to execute these
commands. “Vi editor” is case-sensitive so make sure you type the
commands in the right letter-case.
“i” command: To insert at cursor (goes into insert mode).
“c” command: To delete contents of line after the cursor and insert
new text. Press Esc key to end insertion.
“a” command: To write after cursor (goes into insert mode).
“dw” command: to delete word.
“4dw” command: to delete 4 words.
“A” command: to write at the end of line (goes into insert mode).
“ESC” command: Terminal insert mode.
“u” command: to undo last change.
“U” command: to undo all changes to the entire line.
“o” command: to open a new line (goes into insert mode).
“cw” command: to change a word.
“x” command: to delete the character at the cursor.
“r” command: to replace character.
“R” command: to overwrite characters from cursor onward.
“s” command: to substitute one character under cursor continue to
insert.
“dd” command: to delete line.
“3dd” command: to delete “3” lines.
“S” command: to substitute entire line and begin to insert at
beginning of the line.
“D” command: to delete contents of line after the cursor.
“~” command: to change case of individual character.
Make sure you press the right command otherwise you will end up
making undesirable changes to the file.
You can also enter the insert mode by pressing “a, A, o”, as required.

Moving within a file:


You need to be in the command mode in order to move within a file.
The default keys for navigation are:
“K” to Move cursor up.
“J” to Move cursor down.
“H” to Move cursor left.
“L” to Move cursor right.
You can also use the arrow keys on the keyboard in order to move
within a file.

Saving and Closing the file:


You should be in the command mode to exit the editor and save
changes to the file:
“ZZ” to Save the file and quit.
“:w” to Save the file but keep it open.
“:q” to Quit without saving.
“:wq” to save and quit.

Thank You

You might also like