Quick Tip: Ensuring proper indentation in vim


Quick tip: You can add vim configuration options in source code comments, and vim will load them when it loads the file. For instance, I tend to put
// vim: et ts=4
at the top of my source files, to ensure that tabs are always expanded to four spaces.

3 Responses to “Quick Tip: Ensuring proper indentation in vim”

  1. Simen Says:

    It’s also very useful to add sw=4 to ensure shifting is also moved by 4. Ex. for indentation modifiers “<>” and the autoindent “g=”.

  2. Anders Schau Knatten Says:

    Thanks Simen, and congratulations on the very first post! :)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: