Sometimes, in whatever text editor, tabs length may differ.
In the screenshot below, i show in red how two tab spaces have different length. Sometimes you press tab, and it gives the same space as pressing the spacebar.
How are such distances decided? is it to match a previous/next line?
Typically via so-called tab-stops, which define a certain fixed width on the page (say every 15px). So when you press tab it will transport your cursor to the nearest next tab-stop.
For Cocoa see: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSParagraphStyle_Class/Reference/Reference.html for docs on these.
Some editors even display the tab stops and let the user edit their positions: