Vim Essentials - Introduction

- 3 mins



Vim is one of the most powerful text editors. Although it has a steep learning curve, but it’s worth the time.

I’m starting this series, in hope to provide some useful information, so that, new learners can get help.


By default each unix has Vi installed. But to take full advantage of Vim editor, you have to install full package first.

I’m using Ubuntu, to install vim I need to run just the following commands

    sudo apt-get install vim

Now we can open the file by going to the directory and using the command

    vim myfile.txt

or we can use full path to the file like

    vim ~/home/{username}/docs/myfile.txt

Any of this command will open the file inside the vim editor. Now you might wonder… Hey! this doesn’t look like an existing editor. Where’s the line number or syntax highlighting. Let’s configure it-

In your root directory create a file named .vimrc. You can do it mannually or create it using the command

    touch ~/.vimrc

open in the editor and press i to insert text. i command tells the vim editor that we want to write/insert something into the file.

    vim ~/.vimrc

Insert following lines. Type :wq and press Enter.

	set number // show line numbers
	set cursorline // show active line
	syntax on // syntax highlighting on based on the extension

: opens for any command we want to give. w stands for Write and q stands for Quit. If you want to stay in editor with just inserting the lines then type only :w.

Basic commands

Navigation in vim editor requires four buttons

	H = Left
	J = Bottom
	K = RIght
	L = Top

In previous section we saw that i is for insert and w is for writing in the file. We can delete using d. Fun part is the command d has few associates. If we type d3k it will delete 3 letters on the right. the breakdown is

	d = delete
	3 = no of occurence
	h or j or k or l = direction same as navigation 

so if we type d3l it will delete 3 lines above the selected line.

For undo use u

P.S. All of these commands works in Visual mode only. Insert itself is a mode, and we can’t do these operations when insert mode is active.

Exit editor

You can type :q to quit the editor. However if the file opened in the editor has unsaved changes then this will throw an error. You either have to save the change and quite editor (:wq) or you have exit the editor without changing the editor (q!).


Vim is extremely fun if you are used to it. There are lots of capabilities including plugin management available for Vim. I hope to write about them in the future. Visit Vim official site for details.

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora