Last edited on
Here are some nice tips and tricks I learned while practicing VIM at work or at home.
Setting VIM's syntax highlighter to a particular language
The answer is a single command:
Look up docs about a function, a command, anything
When your cursor is on a word, press shift+K.
dtx => deletes until
x (NOT including character
x). It's super useful to delete until the next parens. For instance:
ctx => lets you go to insert mode after deletion (change vs delete)
Ctags are pretty old fashioned but they work surprisingly well. I use them
mostly at work when diving into unfamiliar Python code.
ctrl+] lets you lookup a symbol,
ctrl+T brings you back to where you were.
Vim has native autocomplete!
ctrl+N to trigger autocomplete and
ctrl+P to iterate over
suggestions. By default Vim searches the current file and opened buffers.
Editing multiple files
You can start Vim and tell it to open multiple files
vim file1 file2 file2.
Better still: when inside of Vim you can tell it to edit a bunch of files.
Let's say I want to edit all my
.scss file. I'd type
path/to/css/files/*.scss. Magic! Now I can do edits, and type
:wnext to save
and switch to the next file in the list. I can also type
:args to see which
files have/have not been edited yet.
Last tip about this:
vim -p path/to/css/files/*.scss will open a Vim session
.scss files, each one opened in a different tab. How awesome is
Each vim user has to have his/her personal .vimrc. I open sourced mine on Github, over there: https://github.com/ArnaudBrousseau/dotfiles/blob/master/vimrc