Here are some of my favorite tips and tricks about vim. They are useful to me and time-saving. I wrote down here to make notes.
First of all, we need generate our own tags for the related project at root directory.
ctags -R
And then I can use the following basic commands for:
- ctrl + ] :jump to the tag underneath the cursor.
- ctrl + t :jump back up in the tag stack.
- :tn :go to next definition for the last tag.
- :tp :go to previous definition for the last tag.
- ctrl + n :auto complete when you code.
Sometimes I used "--exclude" parameter to exclude useless files when generate tags. It would boost process when some files are too large to generate related tags.
To be frank, I don't like using "h", "j", "k", "l" to move cursor, but prefer arrows. Because I always forget their correlation. The following are some my favorite.
- shift + } :move cursor to next blank line.
- shift + { :move cursor to previous blank line.
- :set nu :highlight the line number and you can run ":num" to the line.
- gg :to first line.
- GG :to last line.
- $ :to the end of a line.
- ^ :to the head of a line.