Tuesday, February 26, 2013

Use gvim efficiently

I am fascinated by the feature of gvim/vim. Once you become addicted by it, it's hard to switch to other editor.  Below I have mentioned some techniques using which you can increase your speed of using this amazing command line software.

1)  Running default command

You might have set number of each lines in your edited files in gvim/vim. Or you might be using ignore cases. For this  you have to type command "set num" or "set ic"  every time you open any file. Right ??
But if you are using gvim/vim in linux you can avoid  this tedious process by making one file in your home dir.
make one file name .vimrc and write each command you want. For example you want to highlight line number every time.

make file with name .vimrc

Than writ following command in that file

          set num
          set ic

 you can add whichever command you want in this file.
What happens is that whenever you start gvim/vim these command are automatically executed every time in gvim/vim's command line.


2) Adding abbreviation

Programmer needs to write some syntax frequently. Suppose you want to print something than below syntax in unavoidable.
        $display("");
Each time whenever you want to print something you have to write this syntax.
You can create abbreviation as $d as follows in your  .vimrc file.
       ab $d $display(""); 
  now whenever you want to write $display you can write
     $d  and press Esc. and its done!!!
you can create as many abbreviation as you want. If in you want to add newline between some tax in abbreviation you can you <CR> as shown in the last line of my .vimrc file.

3) Creating aliases in gvim/vim

If you do not like to type  "tabnew" to open new tab in the window? And want some shortcut like t. Than here is the solution. Yes you can create alias using .vimrc file.

just put  write the following line in your .vimrc file as follows.

  cabbrev t tabnew

And it is done. Now next time you open gvim/vim and want to open newtab just write "t" command  in gvim/vim's command line and new line is opened.


Here I have given My .vimrc file

set number
cabbrev t tabnew
ab $d $display("sandip : ");
ab axidebug `sib_axi_report_debug(log,msg_id,$psprintf(""));
ab axiinfo `sib_axi_report_info(log,msg_id,$psprintf(""));
ab ahbdebug `sib_ahb_report_debug(log,msg_id,$psprintf(""));
ab ahbinfo `sib_ahb_report_info(log,msg_id,$psprintf(""));
ab b begin<CR><CR>end



                                                      GO BACK TO INDEX

No comments:

Post a Comment