Sublime Text - Fake whitespace sizing

68 Views Asked by At

Let's say I wish to follow the conventions of a Framework or Community which defines that the application should use 2 spaces.

If I find it easier to read 4 spaces is there an existing method in sublime to make it appear as if 2 spaces are 4, but in reality it is still 2 spaces?

1

There are 1 best solutions below

1
On

I don't think it's possible to do exactly what you are looking for, but I can suggest two alternatives:

1) You could write your entire script using the 4 spaces that you prefer, and then once it is all done, convert it to a text file and parse through it line by line, writing every line to a new file as follows (in Python):

>>> x = "Hello    jshthornton,    here    is    an    example"
>>> print x.replace("    ", "  ")
Hello  jshthornton,  here  is  an  example

This new file that you create will hold all the same information as your original, except it will be in the correct format.

2) You could try editing the true-type font itself so that the spaces are double width; two spaces would take up the same amount of space as four. I have no personal experience editing fonts but in interest I took a look at this, could potentially solve your problem.

Personally I would prefer method 1, it's a simple script & it will let you write your document in the format you prefer with (hardly) any extra work.