Saturday, March 30, 2013

Defining Abbreviation in .gvimrc/.vimrc

We engineers are so lazy people. That is the most basic need for being a programmer. I mean who will like to type so much lines of code if it can be done easily. Gvim/vim gives us this facility for creating an abbreviation. As we know while programming in x language we might need to type certain line of code repeatedly. For example while coding in System Verilog I need to add display messages in many place.
User can create abbreviation as follows.

Suppose I want to create abbreviation for syntex. 
                        $display("sandip  :  "); 
This can be done as follows type the following command in your command line or just put it in your .gvimrc/vimrc file.
                            :ab $d $display("sandip  :");
After typing this command whenever you type $d and then press Esc or tab it expands to full string that we specified   $display("sandip  :");  This techniques of abbreviation saves your time from time consuming typing of code.

For C programmers the most useful abbreviation I would suggest is 

                           :ab #i   #include<stdio.h>  

currently I use the following abbreviation in my .gvimrc/.vimrc file. 

ab $d $display($realtime,"   sandip : ");
ab axidebug `axi_report_debug(log,msg_id,$psprintf(""));
ab axiinfo `axi_report_info(log,msg_id,$psprintf(""));
ab axierr `axi_report_error(log,msg_id,$psprintf(""));
ab ahbdebug `ahb_report_debug(log,msg_id,$psprintf(""));
ab ahbinfo `ahb_report_info(log,msg_id,$psprintf(""));
PREV PAGE                                                 INDEX

No comments:

Post a Comment