Basic gvim commands How to open gvim On
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, * Press n to select next highlighted char Press shift + n to select prev highlighted char To highlight particular word Esc, Ctrl + v, up or down arrow to make selection, shift + I, then give required number of space, Esc Indentation Esc, : %s/char/new_char/g Replace all similar char with new char Esc, : %s/char/new_char/gc y – yes, n - no Replace all similar char with new char one by one Esc, : sp(horizontal) or : vsp(vertical) Esc, : Ex To open one more file in same window To open the current directory
Other important gvim commands Command Use u undo Esc, <no of lines> yy (copy), p (paste), 5 yy, 10 p Copy and paste selected no of lines Esc, <no of lines> dd Delete the selected no of lines : tabnew gg Shft+g (G) New tab Move to start of the file 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
- Slides: 6