Top Useful GVIM Commands
Command Description
dd Delete a single line with vim
ddd Delete 3 lines
u Undo
Ctrl + R Redo
Search (press enter and i to start typing from the
/"word"
same place)
%s/"selected word"/"word to Search and replace (add “g” to replace all work, add
replace with" “gc” to ask for confirmation to replace)
i Enter in the insert mode before the selected letter
a Enter in the insert mode after the selected letter
o Enter to a below new line
Shift + i Enter at the beginning of the line
Shift + a Enter to the end of the line
Shift + o Enter to the new line above the selected line
set number Set the number of the lines
"number" "down/up arrow Do number times down/up
set relativenumber Set a relative number to the selected number
vi ~/.vimrc Save all the set settings that you have done
v Enter in the visual mode to select any line of codes
d Delete the line (after selecting the line)
y Copy the line (after selecting the line)
p Paste (after selecting the line)
yy Copy the full line (after selecting the line)
Change the line instead of deleting (after selecting the
cc
line)
Top Useful GVIM Commands 1
Delete the rest of the line from the cursor selected (after
D
selecting the line)
w Jumps to the new word (after selecting the line)
b Jumps back (after selecting the line)
setf vera Add the colors to system verilog
:set guifont=* Open a pop up window where you can change font size
:sp Open file vertically
:vsp Open file horizontally
:tabe ./* Open files in tabs
Ctrl + d View the files after the sp commands in gvim
:%s/\%Vport/port_up/g Search and replace
Click on the file that you want to open and type gf, this
gf
will open the file
Ctrl + page up/page down Shift terminal tabs
gt Go to the next tab
gT Go to the early tab
melp file1 file2 Meld the following files
Swap the selected line to the next line (Basically it will
ddp
delete the line and then paste the line after the next line)
di" Delete anything between the double “anything”
yi" Copy everything the double “value”
dG Delete everything after the selected point
dgg Delete everything above the selected point
ctrl + w Delete the entire word in insert mode
Delete to the beginning to the line from the selected
ctrl + u
point
ctrl + o Run normal mode command inside the insert mode
= G Properly indent a document
Shift + L/M/H Put the cursor in Low/Medium/High respectively
ctrl u/d Move the cursor up and down half screen
Top Useful GVIM Commands 2
set spell Check for spelling correction
set nospell or set spell! Unset the spell (for unset any command)
ctrl + w c Select the window
:%s///n Get the number of items that is begin selected using *
Change the current working directory to file that you are
set autochdir
in
set nowrap Unwrap the lines in gvim
After doing a start in any string this will keep only the
%g!//d
start line will delete the other line
autocmd that will turn off line wrapping under certain
ac nowrap
conditions
In visual mode, press ‘U’ to make the selection
U
uppercase
To do search and replace in visual mode. This command
:'<,'>s/$/,/
will add , at the end of each selected lines
/word1|word2 To search two word at a same time in gvim
%s/start_string \zs.*\ze This will delete all the between string in start_string and
end_string/ /g end_string
sort u To remove all repeated line
To remove string after a specific string, here “;” is the
:%s/;.*$//
example string
:g/hello/d To delete all lines containing the word "hello”
(visual inside word): Selects the word without
viw
surrounding whitespace
(visual around word): Selects the word including
vaw
surrounding whitespace
To make unix size full screen (This is actually linux
xrandr -s 1*1080
command).
To move between multiple brackets, To fix brackets
Shift + %
issues
color morning To set immediate white color on gvim
Top Useful GVIM Commands 3