Editor Modeline Generator
Note
This page predates tools like clang-format, EditorConfig, and other formatters and is here for historical interest. You're probably better off using something else.
Suppose you have some code which may be editied by people with different text editors and coding style preferences. As discussed by Jamie Zawinski, indentation width, tab width, and indentation behavior can vary widely and can often be a religious (and in the case of Python, sanity) issue.
Some editors are nice enough to let you configure indentation and tab behavior inside the file you're editing. This feature has many different names, such as "modelines," "buffer-local properties", or "file variables". We use the term "modline" here.
The form below lets you create modeline blurbs that you can copy and paste into the file you're editing. Simply select the settings you would like to apply, then copy and paste. You can also create modelines from a set of existing coding styles below.
Official Coding Standards
Coding Standard | Indentation Width | Tab Width | Tab Key Makes |
---|---|---|---|
Python | 4 | ? | Spaces |
Linux | 8 | 8 | Tabs |
Java | 4 | 8 | ? |
Microsoft Visual C++ | 4 | 4 | Tabs |
Microsoft Visual C# | 4 | 4 | Spaces |
Microsoft Visual Basic | 4 | 4 | Spaces |
Microsoft Visual Studio 2010 | 4 | 4 | Tabs |
Perl | 4 | ? | ? |
PHP (Zend) | 4 | ? | Spaces |
Ruby | 2 | ? | Spaces |
Editor Modeline Documentation
Visual Studio modeline support is available via the exTabSettings addin.
Most of the editor- and language-specific information was gathered from a hastily done survey. If you have corrections, please open a bug.
The generator doesn't address braces and other styling issues. This is on purpose.
Links
- Artistic Style, a source code formatter
- Uncrustify, a richly-featured source code beautifier
- Universal Indent, a source code formatter GUI
- Why does Visual Studio use different indentation settings for C# and for C++?
- Design Guidelines, Managed code and the .NET Framework
- Ruby coding conventions, standards and best practices
- Death to the Space Infidels!