Character Spacing Options

Character spacing options are used to control the horizontal and vertical spacing of characters. This dialog box lets you adjust how Source Insight computes the width of spaces, tabs, and common delimiters. The first two settings have no effect unless Line up white space is enabled in the Document Options dialog box.

Horizontal Spacing Options

Horizontal spacing options affect the width of characters drawn when a proportionally spaced font is used and the Line up white space option is enabled in the Document Options dialog box. If enabled, Source Insight will attempt to use a fixed width for spaces and tabs so that spaces and tabs line up the same way they do with a fixed pitch font. Programs generally look better with this turned on if you are using a proportional font.

The Space-Width Character

The space width character controls how wide a single space is, and therefore the displayed width of tab characters (tabs are some number of spaces wide). Source Insight computes a space to be same width as this character in whatever font is used for displaying. For example, the character “1” specified in this dialog box means that a space character will have the same width as the character “1”. (Do not confuse the character with its numeric value 1. Source Insight does not interpret the character’s numeric value.)

Source Insight computes the width based on the space width character so that spaces will scale correctly, independent of the font and the font size used.

Working with Wide Fonts

You may want to change this setting if you are working with a font that has unusual character widths, or if you just want to expand or contract your white space and indentation amounts. A narrower character will shrink the white space, and a wider character will expand it. This width is independent of the tab width setting specified in the Document Options dialog box because the tab width is specified as a number of fixed-width character columns.

The common delimiter character controls the width of delimiters in a way similar to spaces. The delimiters affected are - | \ / and ! which are typically narrow characters in most fonts.

Layout tabstops using monospaced calculations

This option controls how tab widths are displayed. If checked, then the width of a given tab will calculated assuming that you were using a monospaced font. This will generally make tabbed columns of text line up, even if you are using a variable pitched font for displaying your source code.

Layout spaces using monospaced calculations

This aligns space characters to appear how they would if a monospaced font is used. For example, 4 spaces in a row would appear the same width as a tab stop (if the tab width was 4 spaces). Source Insight looks at each line and tries to determine simply when to apply this rule to a space character. If it looks like you meant to line up columns manually using spaces, then it applies this rule. It only applies the rule for 2 or more consecutive spaces. Otherwise, it calculates a space width to be the natural width of a space in the given font. This option is on by default.

Using this option, space size is natural, unless it looks like you meant to line up columns by using tabs and spaces. This is not an exact science!

Source Insight should be doing a good job of showing you how text lines up in a simple display, even if you are using Syntax Formatting. You can also use the Draft View command to see the simple text alignment.

Vertical Spacing Options

These options control vertical line spacing.

Smaller Line Heights

Check this box to compress the line heights in order to show more lines of text on the screen. This is accomplished by reducing the amount of “leading” added to the font by the operating system. Font leading is added to make vertical line spacing look pleasing in printed documents. However, it is not really necessary for editing source code.

Why All The Fuss About Spacing?

You may be wondering, “Why go to all this trouble? Can’t you make a tab stop be ½ inch or whatever?” The answer is a little complicated. The problem is that, unlike a word processor, Source Insight is trying to maintain a text file that other people may want to look at in a simple text editor.

Let’s assume there are other people in your work group that don’t use Source Insight, or that always use a fixed-pitch font for their source code. You don’t want the pretty code you’ve edited in Source Insight to mess up the simple fixed-width tab stops when they look at the code.

A word processing program attempts to show text the way it would be printed on a physical printer. Source Insight is trying to show you how the text would look if you were looking at it in another editor in a fixed pitch font.

In a word processing program, text dimensions are measured in physical units, like inches or centimeters. It makes sense to have a tab stop at say, ½ inch. When the text is printed, the word processor makes sure the tab stop looks ½ inch wide on the printer too.

In Source Insight, tab stops are measured in fixed-size character columns. Source Insight tries to line up tabbed columns the same way it does with a fixed-pitch font.

If Source Insight just did the simple thing of moving to the next tab position, based on the horizontal pixel position, then when you look at the code with a simple fixed-pitch font, there may a different number of tabs than it appears on the screen.

Here is an example. Let’s say somebody wrote this in Notepad, using Courier New (a fixed-pitch font), with tabs between columns so that X and Y, and Q and R line up. Both the words “narrow” and “wide” fit within column 0 - one tab stop, as shown below.

Tab stop:

0

1

2

3

Line 1:

narrow

X

Q

 

Line 2:

wide

Y

R

 

Now, in Source Insight, with rich formatting, “narrow” fits within a tab width, but “wide” doesn't. If Source Insight just pushed Y over by one more tab stop, this is what you get:

Tab stop:

0

1

2

3

Line 1:

narrow

X

Q

 

Line 2:

wide

Y

R

Now Y is aligned with Q. The rest of the columns don't line up anymore. In fact, this is exactly what happens if you turn off Line up white space in Document Options.

When Line up white space is enabled, Source Insight tries to help the situation by lining up tab positions like this:

Tab stop:

0

1

2

3

Line 1:

narrow

X

Q

 

Line 2:

wide Y

R

 

If your code looks like it does above, then you may want to specify a different space width character, such as “M” or “W”, which are wider letters in most fonts. This would have an effect like this, where all tab stops would be wider:

Tab stop:

0

1

2

Line 1:

narrow

X

Q

Line 2:

wide

Y

R

This also works the other way when the text looks a lot narrower than it would be in a fixed pitch font.