- About Extension
- Why Sharp Column Indenter?
- What Is Column Indention / Code Alignment?
- Examples Of Improvements In Code Readability Using Code Alignment
- Steps To Use Sharp Column Indenter
Sharp Column Indenter is a smart source code indenter that indent the code into columns. Also known as ‘code alignment’.
Why Sharp Column Indenter?
The most important aspect of programming is the readability of the source code that you write or maintain. This involves many things, from the syntax of the programming language, to the variable names, comments, and indentation.
Here indention is something where Sharp Column Indenter can help you with.
What Is Column Indention / Code Alignment?
In mathematics you always keep your equals lined up directly underneath the one above. It keeps it clean and lets you know you’re working on the same problem, for example:
Programming is slightly different. We often have a lot of assignments underneath each other, and while they are not strictly the same as maths, there is a close relationship. As such, aligning the equals allows us to quickly spot the relationship.
Further, it makes your code so much more readable. Without alignment, the code is like opening a CSV file in Notepad. But, if you open the CSV file in Excel, it becomes so much easier to read since the columns have meaning.
Examples Of Improvements In Code Readability Using Code Alignment
Take a look at this code:
The idea that I’m talking about is to use something like this below,
The Sharp Column Indenter extension allows you to align by more than just the equals. As you start to see the benefits of alignment, you see that there is so much more to align with.
same code with column indention,
By aligning by the dot we can clearly see that we are setting the same property on each variable, and the thing that changes is the variable name.
This might seem a bit crazy now, but once you start aligning things, it’s addictive.
Steps To Use Sharp Column Indenter
Step 1: Select text you want to align.
Step 2: Select Apply Column Indention command in Edit menu.
I turned Sharp Column Indenter project into a Github repo so you can, you know, contribute to it by making pull requests.
If you have constructive criticism, or know of other tools that do the same thing, please leave a comment.
Subscribe to Code with Shadman
Get the latest posts delivered right to your inbox