Vi Editor Shortcuts

Posted: February 12, 2014 in Linux
Tags: , , , , ,

As we are aware, VI editor works in two mode . One is the Command mode which runs when we press Escape button and give commands and the other one is the insert mode which runs when we press i and type something up.

For a single window option we can always press : and type our command to be executed. One common command is :se nu. Which is the set line number commmand . But, once you quit the window and come back . It will be gone forever.

For making the changes permanent we need to put the commands in .vimrc file. Just type cd to move on to your home folder and open the file .vimrc .

$vi .vimrc
set number

We can also set abbreviations in vimrc file. Some of the frequently used words can be set here.

For example : select * from

When writing queries we will be using select * from quite often . Hence just set the abbreviation in vimrc file as below

iab sel select * from

Once you type sel and hit a space , vi will replace it to select * from .

vimrc file will be invoked when the terminal is loaded. For the effects to be applied on the same terminal where we changed vimrc we need to give the source command

source .vimrc

Or we can just close the existing terminal and open a new one.


Comments are closed.