Sunteți pe pagina 1din 6

Basic gvim commands

How to open gvim?


•On command prompt type:
gvim file_name.file_extension
Insert mode – i
Command mode - Esc
•To save file first press Esc and then press ‘:w’ or ‘:w!’ to over write
•To exit file first press Esc and then press ‘:q’ or ‘:q!’ to quit forcefully
•We can combine w and q, e.g. ‘:wq’ to save and exit

•Exercise:
1.Create a new file with name ‘hello_world.sv’
2.Press ‘i’ to go into insert mode
3.Declare any module
4.Save and exit the file
Other important gvim commands
Command Use
Esc, * To highlight particular word
Press n to select next highlighted char
Press shift + n to select prev highlighted char

Esc, Ctrl + v, up or down arrow to make Indentation


selection, shift + I, then give required
number of space, Esc
Esc, :%s/char/new_char/g Replace all similar char with new char
Esc, :%s/char/new_char/gc Replace all similar char with new char one
y – yes, n - no by one
Esc, :sp(horizontal) or :vsp(vertical) To open one more file in same window
Esc, :Ex To open the current directory
Other important gvim commands
Command Use
u undo
Esc, <no of lines> yy (copy), p (paste), 5yy, Copy and paste selected no of lines
10p
Esc, <no of lines> dd Delete the selected no of lines
:tabnew New tab
gg Move to start of the file
Shft+g (G) Move to bottom of the file
Shft+d (D) Delete line from where the pointer is
/search_pattern Search any pattern in gvim
Recording
• >> qa //start recording
• Pressed keys will be remembered by gvim
• Example of deleting ‘;’ at the end of all lines
• >> press key ‘End’
• >> press key ‘delete’
• >> press key ‘down arrow’
• >> q //stop recording
• >> @a //repeat the recorded sequence
• >> 7@a // repeat the same 7 times
• While qa, key a was stored, @a gave result, likewise many key a,b,c… recording can be
done at the same time. >> qd >> @d
Gvim tutor
• On terminal
• >> which gvim
• >> /path/gvimtutor

Next in Gvim – make your own ~/.gvimrc

S-ar putea să vă placă și