How can I configure Notepad++ to indent spaces consistently?

Let's say I have this bit of code in Visual Studio 2010:

Visual Studio

If I open this in Notepad++ it looks like this:

Notepad++

See that argument2 it out of alignment.

It is not super clear, but in Notepad++ you can see that I am using spaces and not tabs and the font is Courier New (10 pt), which I believe is monospaced (incidentally I am using the "obsidian" style), but it seems like spaces are taking up less space than the characters (about half as much space if you count the dots under public. You can see that four of them cover only to the u).

So what am I missing here - does anyone know how I should configure Notepad++ to display my code aligned like Visual Studio does?


The font you currenty use is not monospaced, meaning the letters have different width. To achieve the effect you want, you need a monospaced font for that (it doesn't matter if it's a serif/sans-serif font).

Best (free) fonts for writing code are imo:

INCONSOLATA
SOURCE CODE

but you can just use Courier New, Consolas or any other monospaced font available on your system.

Settings->Style -> Font and then select the font you like.


I will explain what the actual problem and solution were...

  • I had Courier New set as the Global Styles | Global Override option like so:

    Global

  • And I had Global Styles | Default Style set to Courier New also like so:

    Default style

  • In the C# area I had no explicit style selected like so:

    No style for c#

At this point I asked the question because I figured I was in Courier-New-monospace-land. Clearly I was not...

After a bit I thought, what the heck...I did the last thing remaining to me and went through every option in C# and set the font to Courier New like so:

C# explicit

And low and behold I had Courier New goodness, and it lined up!

Now, not to be someone who gives up I thought a bit longer about the actual options contained therein and rolled back to the situation where I had no explicit option set and then I set just the COMMENT option like so:

Just comment

And that was it!

It seems that for whatever reason the comment did not inherit its font (and a space is considered a comment) and therefore the indentation went all awry.

OK, now that's over I think I will go and have a look at Sublime Text or Vim...