gvim is the most common editor used by all the Unix users. Here are some of the gvim editor commands, used in day-to-day life.
|w||jump by start of words (punctuation considered words)|
|W||jump by words (spaces separate words)|
|e||jump to end of words (punctuation considered words)|
|E||jump to end of words (no punctuation)|
|0||(zero) start of line|
|i||start insert mode at cursor|
|I||insert at the beginning of the line|
|a||append after the cursor|
|A||append at the end of the line|
|o||open (append) blank line below current line (no need to press return)|
|O||open blank line above current line|
|Esc||exit insert mode|
|C||delete from cursor position to end of the line|
|:E||edit a file in a new buffer|
|:sp||open a file in a new buffer and split window|
|Ctrl+ww||switch cursor between windows|
|Ctrl+wq||quit a window|
|Ctrl+w gf||Edit existing file under cursor in new tabpage|
|Ctrl+w f||Edit existing file under cursor in split window|
|gf||Edit existing file under cursor in same window|
|Ctrl+wv||split windows vertically|
|:%s/old/new/g||replace all old with new throughout file|
|:%s/old/new/gc||replace all old with new throughout file with confirmations|
|n||repeat search in same direction|
|N||repeat search in opposite direction|
|/pattern||search for pattern|
|:w||write (save) the file, but don’t exit|
|:wq||write (save) and quit|
|:w!||force write to a read only file|
|:q!||force quit and throw away changes|
|yy||yank (copy) a line|
|2yy||yank 2 lines|
|dd||delete (cut) a line|
|p||put (paste) the clipboard after cursor|
|P||put (paste) before cursor|
|dw||delete (cut) the current word|
|Ctrl+v||start visual block mode|
|.||repeat last command|
|r||replace a single character (does not use insert mode)|
|R||replace characters till Esc is pressed|
|J||join line below to the current one|
|:tabnew||open new tab|
|:tabnew %||open same file in new tab|
Remember that vim stores the recordings in macros.Following are the steps for recording in gvim:
- Start recording by pressing q, followed by a lower case character (a-z) to name the macro.
- Perform any editing, actions inside Vim editor, which will be recorded.
- Stop recording by pressing q.
- Play the recorded macro by pressing @ followed by the macro name.
- To repeat macros multiple times, press: N@macro name. NN is a number.
Ex. 1@a (or @a) will play recording 1 time stored in buffer ‘a’, 2@a will play it 2 times and so on.
You can store 26 different recordings at a time!
Also, I would like to share vimrc and vim scripts for some of the trendy shortcuts.
Just download and extract the zip file and perform the following steps:
- Copy and Paste the file .vimrc, .gvimrc and .vim directory to your home directory.
Ex.: cp –r .vimrc .gvimrc .vim ~/
- You will notice that .vimrc and .gvimrc are exactly the same, this is because some xterm configured terminal and some versions of gvim uses .gvimrc instead of .vimrc. So it is better to have both in your home directory.
- Search ‘please_replace’ in the files .vimrc and .gvimrc and navigate to that line. Replace the absolute path with the path of your home directory where .vim folder is present.
Ex.: Esc -> /please_replace -> Enter -> Line 31 (for now) -> Replace with /home/your_user_name/.vim/….
- That’s all. Now you can open any file in gvim and see SystemVerilog syntax applied automatically.
- One more thing, the vimrc and gvimrc uses map and imap commands for mapping daily usage commands. You can add similar commands to the file.
Just type $d and it maps it to $display(“”); full command
endc for endclass
endm for endmodule and so on.
These are some of the commonly used shortcuts, feel free to share more commands that maybe helpful.