Tuesday, April 30, 2013

Some useful gvim/vim tricks

Hi Here some very much useful commands are given for programmers who use gvim/vim as their editor.

Going Forward in file

Suppose you are seeing log of some code that you have written in some programming language. As I am ASIC engineer lets say System Verilog. Now in your log file there is some compilation error in some particular file which is shown with full path in log. right??
Lets assume that compiler is giving error in file
    /home/sandipb/temp/system_verilog.sv : Undefined Veriable

As you are using powerful gvim/vim software just put your cursor to that directory path which is shown in blue color in this post(you will have your own path in your log) and press "fg" and you are in the /home/sandipb/temp/system_verilog.sv

Back to Directory

Now after doing some necessary changes in the edited file you can go back to log file by simply typing the following command.

              :bd 
This the command for going back to directory.


Spliting file Vertically as well as Horizontally 

You can easily split your vim/gvim window using split commands. To split your gvim window use split  command.
 :split
And to split your gvim window vertically use vsplit command.
 :vsplit

In some cases where you want to directly open specific file in split mode. In this case simply give file path name as argument of split / vsplit command.
For example you want to open file ~/abc/xyz.txt in new splited window.
User command  :split ~/abc/xyz.txt or :split ~/abc/xyz.txt

Open or reload file in gvim/vim
Generally we use tabnew to open a file when we want new file to be opened in new tab and current working file remain open.
To open a new file without giving path. You can use :e filename command for this.
To reload the file just write :e

Auto word or line completion in gvim/vim
Programmers always need to define variables and need to use them. One basic requirement for using variable is that name should be same at all places !!!!!! For this thing gvim provides facility to auto complete you variable name.
Cntl + p & cntl + n used to auto complete the word. There is not much difference using cntl + p or cntl + n.
cntl + p auto complete the word in previous direction.
cntl + n auto complete the word in next direction.

Same way we have one auto complete command for completing lines.
That is cntl + l  this command auto complete the line.

These are the tricks to work faster that I am able to learn in my 2 and half year of experience.



Previous                                 Index


Tuesday, April 2, 2013

Configuration of .gvimrc for UVM highlighter

As we have discussed in previous post how we can create simple groups for highlighting purpose. I have created highlighter for UVM(Universal Verification Methodology).
If you want to learn how to code highlighter you can see it in following links.

                               Configuration of magic box .gvimrc

                               configuring color property for highlight group

                               define complex group for highlighting

I have configured some variables for highlighting purpose while using uvm methodology for verification. Simply copy this code in your .gvimrc/.vimrc file and it is done.


                    syntax keyword uvm_keyword uvm_object
                    syntax keyword uvm_keyword uvm_agent
                    syntax keyword uvm_keyword uvm_transaction
                    syntax keyword uvm_keyword uvm_sequence_item
                    syntax keyword uvm_keyword uvm_sequence
                    syntax keyword uvm_keyword uvm_sequencer
                    syntax keyword uvm_keyword uvm_report_object
                    syntax keyword uvm_keyword uvm_component
                    syntax keyword uvm_keyword uvm_monitor
                    syntax keyword uvm_keyword uvm_scoreboard
                    syntax keyword uvm_keyword uvm_driver
                    syntax keyword uvm_keyword uvm_test
                    syntax keyword uvm_keyword uvm_env
                    syntax keyword uvm_keyword uvm_subscriber
                    syntax keyword uvm_keyword uvm_config
                    syntax keyword uvm_keyword uvm_config_db
                    syntax keyword uvm_keyword uvm_analysis_port
                    syntax keyword uvm_keyword uvm_tlm_extension
                    syntax keyword uvm_keyword uvm_tlm_if
                    syntax keyword uvm_keyword uvm_field_int
                    syntax keyword uvm_keyword uvm_config_db
                 
                    syntax keyword uvm_function seq_item_port
                    syntax keyword uvm_function get_next_item
                    syntax keyword uvm_function try_next_item
                    syntax keyword uvm_function build_phase
                    syntax keyword uvm_function connect_phase
                    syntax keyword uvm_function run_phase
                    syntax keyword uvm_function uvm_phase
                    syntax keyword uvm_function raise_objection
                    syntax keyword uvm_function drop_objection
                    syntax keyword uvm_function run_test
                 
                    hi uvm_keyword term=bold  gui=bold guifg=red
                    hi uvm_function term=none  gui=none guifg=green


PREV PAGE                                           INDEX                                                     Next