VIM: All you need to know about it

13 / Feb / 2014 by Vikash Jha 0 comments

Vim is an extremely practicable text editor which allows efficient text editing. It is considered as one of the most handy tools for programmers, allowing them to edit configure files and sometimes also considered as IDE. Though, it not just limited to editing configuring files, it also allows a user to edit text files and write emails etc.

In this blog, I have discussed some of the most useful and frequently used commands that can save a lot of your time in development cycle.

We will start with one of the most useful set of commands:

 

WORKING WITH MULTIPLE WINDOWS

1. Splitting window horizontally to load another file

:split filename e.g :split file2.c


Note : To switch between opened windows, use CTRL+ WW

2. Splitting window vertically to load another file

:vsplit filename e.g :vsplit file2.c


Note : To switch to left buffer, use CTRL + W + H and to right buffer use CTRL + W + L

3. To save all file from opened multiple windows and exit

:wqa

4. To close the current window

:hide

5. To close all the window except the current positioned window

:only

 

Example of multiple windows

ADDING VARIABLE TO  /etc/vim/vimrc

1. Setting Number line for every file

set nu

2. Highlight your search

set hlsearch

3. Applying indentation to file

set autoindent

4. Enable mouse click to position cursor at any point

set mouse=a

5. Change the background and foreground color of Vim

highlight Normal ctermfg=grey ctermbg=dark blue

6. Show Real Time Search

set incsearch

OTHER EASY TRICKS

1. Editing in Stream by transferring the output of any command to vim

cat /etc/passwd | vim -

2. Encrypt your file using vim

vim -x filename

While encryption, it will ask you for encryption key, you can use the same key to decrypt the file or to read/modify the contents of file.

Hope these Vim commands will help you accelerate your development and save a lot of time.

FOUND THIS USEFUL? SHARE IT

Tag -

Linux vim

Leave a Reply

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