Home / Server / Linux / CentOS / Vim Commands in RHEL/CentOS Linux for Beginners

Vim Commands in RHEL/CentOS Linux for Beginners

Today we will learn some of the basic tasks of vim commands in Linux System. Everybody knows that different kinds of editor is available for opening text files. As for Ex- Joe, Nano, Emacs, Pico, vi/vim, edit etc. Through text editor, we can open, edit and write file. Vim is the update version of vi editor. Vim editor can show colored text. In this tutorial we will learn few tasks of vim editor.

If you need to install Linux OS in VMware Machine, please visit my other post –

You can also watch Linux installation videos RHEL 7 Installation & CentOS 6.5 Installation

Basic vim commands in Linux:

1. For opening file using vim editor:
# vim sample.txt

2. This command will open sample.txt file without saving condition:
# vim –m sample.txt

3. Open file in read-only mode:
# vim –R sample.txt

4. To open file without creating swap file:
# vim –n sample.txt

5. To save file in encrypted mode:
# vim –X sample.txt

Vim editor have three Modes:

1. Command mode
It works for cursor movement and screen re-positioning and text search.

2. Insert mode
In this mode, it is used for inserting the text or data

3. X mode
used to save file or exit from the file.

Now we will discuss about the three modes of vim editor:

1. Command Mode:
h   =>  Courser will move left
l    =>  Courser will move right

j    =>  Courser will move down
k   => Courser will move up

b   =>  Courser will move one word left
w   =>  Courser will move one word right

(    =>  Courser will move one sentence left
)    =>  Courser will move one sentence right

{    =>  Courser will move one para left
}    =>  Courser will move one para right

gg    =>   Courser will go to the first line
5gg   =>  Courser will go to 5th line
Shift+g   =>   Courser will go to end line

Text Search Mode:
/text   =>  It will find the “text” word from down line
?text   =>  It will find the “text” word from up line

Text/word copy paste and delete:
i) To delete one line press “dd” and to paste press “yy”
ii) To delete one Letter press “dl” and to paste  press “yl”
iii) To delete one word press “dw” and to paste press “yw”

To paste any copied line:
p   =>   paste below the present line
Shift + p   =>  paste upper of the present line

2. Insert Mode:
i   =>   for write text from cursor back side
a  =>   for write text from the cursor front side
I   =>  for write text from the first of any line
A  =>  write text from the end of any line

3. X Mode:
To exit from insert mode to x mode needed to press “ESC” button on keyboard.

:w => Save the file after editing something
:q => Exit from the text editor without saving
:wq!  =>  Save file and exit from the text editor

X mode have other few works:

:set nu  => To see the hide line numbers
:set nonu  =>  To hide the line number

Video tutorial for this post:

Want more tutorials !!!

Please, subscribe my channel – Youtube Channel

Like Facebook Fan Page – IT Zone

Follow on Twitter – IT Zone

About Shyamal

Avatar of Shyamal
Shyamal is our resident tutorial master. He has years of experience with WordPress Platform and is a professional blogger with a special interest in Social Media, Internet Marketing and Web Design. Actually, he is also working on a IT Company as a System Administrator in the fields of Linux and Windows Server, System Administration and Networking.

Check Also

disable ipv6

How to Disable IPv6 on CentOS/RHEL 7

Post describes procedure to disable IPv6 on CentOS/RHEL 7. There are 2 ways to do …

Leave a Reply

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

Advertisment ad adsense adlogger