Coding Style Guide
From Veximwiki
Contents |
Coding Style Guide
Like most open source projects, we have a number of developers who work together to write this great software. In order to maintain the codebase, we need a consistant coding style. It doesn't really matter what this coding style is, just that it be consistantly used so that we can all find the code we want.
Line width
Please limit lines to 78 characters. While this may seem like an unfairly small number, there are a number of good reasons for it:
- 78 characters actually works very well, it encourages thought about how you format your code.
- The default width of a Unix terminal window is 80 characters but
- using 78 instead of 80 has the advantage of allowing you to quote the source code once in an email. And you will not miss the two characters you loose compared to 80 characters.
- When you have multiple terminals open, even on a large screen, having to make them all 150 characters wide quickly become unusable
Indentation
Please indent all code using four spaces.
- Different editors tab in different ways. A tab character to you might be 8 spaces to the next person and 4 spaces to the next.
- In vim, the following command will set the correct tab parameters for you:
- :set expandtab (when you press 'tab', you insert space)
- :set softtabstop=4 (this makes it feel like you are using 'tab', when you press 'tab', 4 spaces will be inserted, when you backspace 4 spaces will be removed)
- :set shiftwidth=4 (the number of spaces to automatically indent)
Bracketing
Brace and parenthesize in K
