sourceInsight tabs indentation

3.4k Views Asked by At

I have sourceInsight 4.0 version. I set the tab width to 4, and also set "Expand tabs to space. However, I still have indentation problem - for example: I have function decleration in one line, and in the second line I want to add the function parameters aligned with the (. This looks ok and aligned in sourceInsight editor, but when I open the document in another editor the indentation is not the same. What is missing in configuration? I tried also to change the "Auto Indent.." values and it didn't help

3

There are 3 best solutions below

0
On

For example,if you've set the tab width as 2 in Source Insight.
When you change to another editor, it may look messy, because tab width is not 2 in that editor.
The solution is to set the tab width accordingly with Source Insight.

0
On

You should set tab width and "expand tabs" for each file type.

If you set them for java file type, they will not affect to other file tyle like c, c++, html, text etc.

enter image description here

If you set them for all file type you need, how about checking the tabs are expanded into spaces?

0
On

I believe your problem is that you are trying to align the parameters of a function using tabs... This doesn't work. The crux of the issue is that if you use tabs, and make it look good on your editor, someone else will have different tab spacing on theirs, and the code won't look good on their editor. There's numerous articles that describe this in more detail (see here for example).

For source insight, the issue is compounded because by default it changes the font size based on context, meaning spaces are a different width than the characters that might be above it. This makes any meaningful alignment almost impossible (and definitely not portable with other editors)

What I would suggest:

  1. In the Options->File-Type-Options, click on the Screen Font... button and select a fixed width font (courier new, consolas, etc).

  2. Under Options->File-Type-Options, select 'Visible tabs' and 'Visible spaces' for all your basic file types. I believe it defaults to a light grey color that's barely noticeable unless you're looking for it.

  3. Go to Options->Preferences->Syntax Formatting, and select Use only color formatting

or

  1. Then go to Options->Style Properties. Walk through the sytle names, and change all styles to have Scale(%) to be =. (takes longer, but allows more control -- you can make preprocessor defs bold and so forth and so-on)

  2. Decide on a tabbing scheme -- either:

    tabs for indentation, spaces for alignment (my favorite, though not overly popular overall)

    spaces for everything (this is quite common, because it's simple to describe, and hard to mess up)

    tabs for indentation, but don't do alignment (my least favorite).

Hope that helps