Getting rid of weird HTML indentation in Visual Studio Code

When editing HTML files in Visual Studio Code I have always been driven away by the weird auto-indentation when typing out closing tags. Since I am used to writing opening and closing tags before adding any further child elements, I have refrained from using VS Code for this purpose.

In the latest versions there seems to be certain improvement, though it still isn’t perfect. Therefore I decided to dig into the topic a little more and believe I found a solution to satisfy one’s needs. We shall achieve this by adding a simple line of JSON into user settings within Visual Studio.


We’ll start off by launching a new instance of Visual Studio and opening an HTML file. When adding some content as described above, we end up with something like this.

How I don't like it
How I don’t like it!

You can clearly see that the body tag is indented to the right when it shouldn’t be.   Though this might be a thing of personal preference I wanted to help those, who are feeling the same as me.

The workaround here is rather simple. Just bring up Command Palette using the Control + P (on Windows) or Command + P (on macOS) key combo and search for “user settings”. Another approach is to hit Control + , (on Windows) or Command + , (on macOS). This will open two JSON files. The one on the right will be empty. Here we will set the editor.formatOnSave setting to true. So make your file look like this.

Format on save
Format on save

Now you can go back to your HTML file and hit save. VS Code will automatically format the file as to your desire.

Edited file
Edited file

C# 7.0: Tuples

Microsoft has recently unveiled some changes, that developers will be introduced to in the future release of C#, the C# 7.0.

Among all developers who see sharp 😀 , there is an enormous amount of anticipation of the features in the final release. In the meantime, I decided to interpret you one of them today. So let’s dive into it!

Tuples, I'm ready!
[1]: Tuples, I’m ready!

One of those things, that may please current developers and possibly attract new ones, are tuples. Tuples or tuple-like syntax can be found in many languages.

The universe before C# 7.0

In previous versions of C#, it could have been achieved this way using the out keyword when passing variables as parameters to a method:

This keyword allowed multiple values to be “returned” by the method. I am using apostrophes, because it is not really a tuple case-in-point and the GetTwoValues doesn’t really return any value, as well.

Getting closer…

This example in Python shows tuples the way they are commonly understood.

The example here is pretty straightforward and easy to understand. I personally haven’t been in a position wanting to return two or more values within a method, but is sure a step forward in the versatility of the C# language.

C# 7.0 at last

Let’s finally examine how tuples will look like in C# 7.0.

This sample works the same as the other one with out keywords shown earlier in the article. We get the values as elements in a tuple, store them into a variable of unknown type and then print them to the console. Each value is stored in the resulting container as an element called Item1 (Item2, Item3 and so on).

Item1 and Item2 is not overly descriptive. To avoid this woe, we can make use of named tuple elements. Let’s edit our code a bit.

The only, but important, change here is the switch from Item1 and Item2 to First and Second. Hence, making our code far more readible.

What do you think about C# 7.0 and tuples? Leave a comment down below.

Source: MSDN