How to install and use Vim text editor on CentOS7

blog background image

Introduction

The most powerful text editor accessible from the command line is vim editor. With most UNIX systems and Apple OS X, it is included as "vi".

You can get basic ideas about “Vim” by reading this blog.

Now we will see what can be done with "Vim" and how to do.

  • Installation
  • Opening Vim
  • Modal Editing
  • Navigation
  • Editing
  • Managing Documents

Installation

To install the "Vim", execute the following command and see the image below.

 

sudo yum install vim

 

Press the enter button to install "Vim".

From here, press Y to update or download "Vim".

Opening Vim

To open any file in the command line, press the Enter button with "vi" before the filename and then open your file.

If you want to create a new file via vim, then use the following command.

vim newfile

 

To write something in the new file, press "cc". When finished, press the "Esc" button. To save the file: Press ":x".

Modal Editing

The main difference between vim and other text editors is that vim is a "modal" editor. Most other editors have only one mode. Vim works with many modes.

Normal Mode

In Normal Mode, if you want to edit, copy and paste any text after pausing, press the "Esc" button and you can pause.

Model Editing has insert mode, visual mode, and command mode outside of the normal mode.

Navigation

We use arrow keys from the keyboard to move right, left, top, and down while editing or editing any text on the computer. But in Vim you have to press some word to work.

Now we will see, how to move left, right, up, and down on Vim when we edit or create a new file.

  • h- press for move left side
  • j- press for the move down
  • k- press for the move up
  • l- press for the move right

Editing

Commonly used commands for text editing in Vim.

Removing Text

  • x - Delete characters in cursor position
  • d - Press d to delete the direction you specified after executing the command. For example, "dl" deletes a letter to the right.
  • dd – For delete a line.
  • D - Delete from the current location at the end of the line.

Copying and Pasting

  • y - Copy.
  • yy - Copy the whole line.
  • Y - Copy to the end of the line.
  • p - Paste the copy below the current line to the last line.
  • P - Paste the copy in the last line above the current line.

Managing Documents

Vim mainly manages the document through the command. In order to manage a document in the vim, all the commands have to be used ":" this symbol before the command.

  • :q - Leave the Vim. If the changes are not saved, it will be lost.
  • :q! - Leave the Vim. Discard unsaved changes.
  • :w - Save Changes. If you want to save a different location, add a space and a file name, or it specifies a saved location for your first time.
  • :e - Edit the next file
  • :bn - Edit the file next to the file that is open.
  • :bp - Edit the previous file that vim has open.
Starting Only
$0.48/Mon
Up to 75% OFF - Black Friday Hosting Deals!

Related Blog Post

Create, collaborate, and turn your ideas into incredible products with the definitive platform for digital design.

How to create cPanel backup from command line

12 December 2022

How to create cPanel backup from command line

This article explains how you can create cPanel backup from the command line, using your own username and password.

Read More
How to install Webuzo Panel on linux Server

12 December 2022

How to install Webuzo Panel on linux Server

Webuzo is a popular alternative to cPanel, a widely used web hosting control panel developed by cPanel, Inc.

Read More
What are NFT Domains?

02 February 2022

What are NFT Domains?

NFT domains are new web extensions that are deployed using ERC 721 and Polygon Network, except .zil which uses Zilliqa.

Read More
How to Delete a MySQL® Database

01 January 2022

How to Delete a MySQL® Database

This document describes how to manually delete a MySQL® database from a cPanel & WHM server. This is useful if, for exa

Read More
How to get Transfer Authorization Code from GoDaddy

11 November 2021

How to get Transfer Authorization Code from GoDaddy

To transfer your domain with us then must need EPP Code.

Read More

Got a question!

Contact us at