GVIM Commands
GVIM commands and their usages
If you work in VLSI or any Linux-based environment, you’re likely no stranger to scripting, log analysis, and report generation. Whether you’re debugging a TCL script, parsing log files, or querying design reports, efficiency is key. Manually editing files is tedious and error-prone—this is where mastering GVIM (Graphical Vim) becomes a game-changer.
Below, we’ll explore essential GVIM commands tailored for engineers who want to streamline their workflow. Let’s dive in!
If one file is opened and we need to open a file to compare with this, then use below command.
tabe gvim <filename.tcl>
- If you have opened the gvim and want to replace some string, then use below command.
:%s/old_string/new_string
:%s/old_string/new_string/g
:%s/old_string/new_string/gc
Here “g” represents the replacement and “c” represents conditional replacement.
- If you want to append a string at all the lines in the file, open gvim and use below command.
:%s/$/<String to be append>/g
- If you want to prepend any string at the beginning of all lines present in the file, then use below command.
:%s/^/<String to be append>/g
- If you want to delete the lines other than a particular string, then use below command. This will delete all the lines in a file and will keep the lines contains ERROR.
:g!/ERROR/d
- Simillar to above if you don’t want to keep lines which contains particular string then use below command. The difference between the above and below command is “!” sign.
:g/ERROR/d
- If you have all the lines column and wants to change it to row, then use below command.
:%s/\n/ /
- If one wants to split the file horizontally then use below command.
:sp file2.tcl
- If one wants to split the file vertically then use below command.
:vsp file2.tcl
- If one wants to show the line number, then use below command.
:su nu
- If you want to hide the line numbers, then use below command.
:su nonu
- If you want to jump at some particular line, then use below command.
:n
Where n can be any number.