How do you enable file specific tab indent settings in VIM?

cmcginty picture cmcginty · Apr 30, 2010 · Viewed 9.1k times · Source

I believe there is a method to write a comment in a file that vim will use to override default tabbing and indent values.

Can someone point me to information about this feature and how to use it?

Answer

Tim Henigan picture Tim Henigan · Apr 30, 2010

Per-file settings can be done using "modeline magic".

The basic idea is that you can add a comment to an individual file like this:

/* vim: set tabstop=8:softtabstop=8:shiftwidth=8:noexpandtab */ 

Within vim, you should review: