Wednesday, February 27, 2013

Use gvim efficiently-2

**) Open different files in same window with different tabs

Sometimes you write two or more filenames in front of gvim command  and find that those files are open but you have to writ :n or :N command each time you want to switch from one file to another.

In this case to can open different file in different tabs in same window by using the following command.
    gvim -p file1.sv file2.sv
and its done.

 **) adding same text in multiple lines using gvim

suppose one file having following text is edited in gvim.

   bit  var1 ;
   bit  var2 ;
   bit  var3 ;
   bit  var4 ;
you want to add [31:0] in front of variable name in each line. NO NEED TO ADD EACH AND EVERY LINE IF YOU ARE USING gvim.
jist press cntr+v  keeping courser  ant 4th place of 1st line. then reach to 4th line vertically. Now you have selected one-one place in each line. Press shift+i and write text [31:0]. Then press Esc. And you have done it. This is the most amazing feature of gvim I have found. I am sure you will like it.

**) Make some tedious editing easy using gvim

Suppose you want to repeat some editing  wile editing file. Your last editing step is always recorded in your gvim buffer.

add_              _data      ad_dr         aw_len
if you want add "gvim " at the places where _ is given.
--> press Esc and go to that place of edting. Press "i" to move into insert mode. Then type "gvim"  at that place than type Escp. Then goto "_" in second word. Then press "." and its done. As gvim stores last action and by press sing . it is repeated you do not need to write four times "gvim".



                                                      GO BACK TO INDEX

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