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:

:q!

###### #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
or
:q!    quit without saving your changes
or
wp   quit and save changes
x      quit and save changes

• h – Left
• k – Up
• l – Right
• j – Down
###### Text Editing

Deletion

x


Insertion
This puts the cursor before the current position

i


Appending
This puts the cursor after the current position

a


Open commands
This puts the cursor below the line:

o


And this puts the cursor above the line:

O


Undo Command

u

###### #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:

[OPERATOR] [NUMBER] [MOTION]


Operators
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
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 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 dw  Deleting to end of line d$


Deleting 4 words

d4w


Move to the bottom of a file

:G


Move to the start of a file

:gg


ctrl + g


12 + G

###### #Search

Search page after the cursor position

:/cats


Search a page before cursor position

:?lion


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

#1

vim file1.txt file2.txt  // open two files
:args // seek current file name is opening


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

:tabe b.txt

:split or sp  // split horizontal