Vim modeline magic

Prem Sichanugrist
Sikachu's Blog
Published in
1 min readApr 2, 2020

--

So I have this ~/.aliases file in my home directory that contain all of my aliases. However, everytime I open the file I have to do :set filetype=bash to make Vim syntax highlight my file … until today!

After a quick Googling for “vim magic comment”, I found this amazing tips:

This is exactly what I wanted. So, I just added this on the top of my file:

# vim: set filetype=bash:

And Voilà! Custom syntax highlight for this particular file. 💯

--

--

Senior Developer at Degica. I also contribute to open source projects, mostly in Ruby.