i Vim editor – All things in moderation

Vim editor

Why is VIM ?

VIM, or Vi Improved, is an extremely powerful text editor that lets you do almost everything using keyboard shortcuts. You can replace text in a document, move or delete lines, automate edits and more without ever reaching for the mouse. If you want your work effective on Linux you have to know it , after that it is one of the fisrt steps if you want to explore LINUX .

How to install VIM ?

By default , vim not be installed , you must install it .
On Ubuntu/Debian

sudo apt-get install vim

On Centos/Redhat

sudo yum install vim
How to use it ?

If you have always used a graphic text editor like Notepad or TextEdit, you are likely to find Vim confusing but spend some time with the editor and it will be difficult for you to go back.
So, Let’s start !

#Test you install

Open Termial and type command below:

vim -v

To quit type:

#Work with you file

**Create a newfile or open file is existed **

vim filename.txt

Quit or save **: enter Command Mode with **ESC, then just type:

:q!    quit without saving your changes
wp   quit and save changes
x      quit and save changes
#Move cusor around
  • h – Left
  • k – Up
  • l – Right
  • j – Down
Text Editing



This puts the cursor before the current position


This puts the cursor after the current position


Open commands
This puts the cursor below the line:


And this puts the cursor above the line:


Undo Command

#Operators and Motions , Counts, and Combining Them

Commands are broken down into these parts: **Operator, Numbers, Motions **
When to put together , the Vim Command will look something like this:


Operators are actions.
Here’s a list of common operations:

d - Delete( like a "cut")  
c - Chagne  
y - Yank  
p - Insert last deleted text after cursor (put command)  
r - Replace  

Motions provide context to your Operators
Here’s a list of common motions:

w - Until the start of the next word, EXCLUDING its first character.  
e - To the end of the current word, INCLUDING the last character.  
$ - To the end of the line, INCLUDING the last character.  

And some additional others:

    w – Forward by word  
    b – Backward by word  
    ) – Beginning of next sentence  
    ( – Beginning of current sentence  
    } – Beginning of next paragraph  
    { – Beginning of current paragraph  
    ] – Beggining of next sect  
    [ – Begginning of current section  
    H – Top line of screen  
    L – Last line of screen  

Counts are optional and simply let you put a multiplier to your command and motion. You’ll see how these work in the examples belows.
Deleting a word


Deleting to end of line


Deleting 4 words

#Quick page navigation

Move to the bottom of a file


Move to the start of a file


View your current page line

ctrl + g  

Jump to a specific line with:

12 + G

Search page after the cursor position


Search a page before cursor position


Go to next or previous math

n or N  

Other great shortkeys

Slect paragraph
Hit capital v then pressing down your arrow keys and select everthing you need

I think it’s enough for start , try practice it , forget your mouse you will feel** the mafic of VIM.**

Open multiple files


vim file1.txt file2.txt  // open two files  
:args // seek current file name is opening  
:n // jump to next file  
:prev // jump to previous file  

when you are opening file a.txt and you want open file b.txt

:tabe b.txt  
:tabp  // jump to previous file  
:tabn // jump to next file  
gt or gT // switch tab when you are not in editing mode  

Split window

:split or sp  // split horizontal  
:vs or vsp // split vertical  
Ctrl + w( two times)  // to switch between windows  
  1. OpenVim
  2. Vim Advnentures
  3. Vim Cheat Sheet

Leave a Reply