Home Download Buy Blog Forum Support

spacing visually totally wrong

spacing visually totally wrong

Postby ffw on Fri Jan 18, 2013 11:43 pm

Hello,

I am a new user of Sublime Text. And although I like the editor, there are a few things missing. That said, my primary problem right now is that spacing seems to be totally off visually. I changed the user settings to use 2 spaces for indenting (instead of the usual 4).

Now when I code something in python like:

Code: Select all
testcode = dict(test_variable1='some random quote',
                test_variable2='another random quote')


it looks visually in the editor like:

Code: Select all
testcode = dict(test_variable1='some random quote',
           test_variable2='another random quote')


Note the indenting is visually totally wrong: test_variable2 and dict seem to be aligned, however both test_variable1 and test_variable2 start at position 17 of each line. So although the spacing is accurate, it looks like it is not.

Same for the ruler I added. I would like to have a ruler at 80 characters so I always know when I am getting to the end of my line (I try to code everything within 80 characters). However, if I set the ruler to position 80 it looks visually more than 160 spaces. Only if I set the ruler value to 39 it comes closest to 80 characters for a majority of all lines, but just a slight majority and not all sentences.

In all my previous editors I have used (of which Geany was the my trusted sidekick for the last 4 years) setting rulers at the 80 character mark was never a problem. And also visually showing the spacing right was not either. This is causing me a lot of headache and a lot of manual code fixing.

Any ideas how I can fix this?

Thanks
ffw
 
Posts: 3
Joined: Fri Jan 18, 2013 11:33 pm

Re: spacing visually totally wrong

Postby adzenith on Sat Jan 19, 2013 4:13 am

Are you using a fixed-width font?
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: spacing visually totally wrong

Postby ffw on Sat Jan 19, 2013 10:51 am

Hello Adzenith,

I am using the default that came with the installation. I did not set any in particular. Is there any you can recommend?

Thanks,
ffw
 
Posts: 3
Joined: Fri Jan 18, 2013 11:33 pm

Re: spacing visually totally wrong

Postby adzenith on Sat Jan 19, 2013 2:51 pm

Personally I use Consolas, which comes with Windows or Microsoft Office, but any fixed-width font will do.
The important thing is just that all the letters have the same width—otherwise, if you're using a proportional font, Sublime Text will measure everything based off of the width of a space (I believe) which is generally pretty thin. This would explain why your rulers are so far in.
It may be that you have some interesting setup and you're missing the font that Sublime Text looks for by default, and it's falling back to a proportional font.
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: spacing visually totally wrong

Postby ffw on Sun Jan 20, 2013 3:47 pm

Hello adzenith,

Thanks a million, that seems to have solved the problem. I changed the font_face to "Droid Sans Mono" and all spacing seems to be correct now.

For future reference (if anyone else runs into this thread), the following links may be useful:
http://en.wikipedia.org/wiki/Monospaced_font
http://en.wikipedia.org/wiki/Samples_of_monospaced_typefaces
http://www.codeproject.com/Articles/30040/Font-Survey-42-of-the-Best-Monospaced-Programming

Thanks again!
ffw
 
Posts: 3
Joined: Fri Jan 18, 2013 11:33 pm

Re: spacing visually totally wrong

Postby foxbunny on Sun Jan 20, 2013 4:00 pm

ST2 has always had indentation issues in Python, and it's nothing to do with fonts. For example:

Code: Select all
# ST2
some_func(arg1,
    arg2)

# PEP8
some_func(arg1,
          arg2)


Code: Select all
# ST2
some_list = [item1,
item2]

# PEP8
some_list = [item1,
             item2]


And so on. Not even edge cases. These are quite common.

EDIT: Speaking of PEP8, does anyone use autopep8? Could it be used as a workaround for indentation issues?

EDIT2: Ok, installed autopep8, and the Ctrl+Shift+8 binding can fix the poorly indented lines. Works on whole file if there's no selection, or on selected lines.
foxbunny
 
Posts: 5
Joined: Tue Jan 15, 2013 5:37 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot] and 14 guests