Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 182513 - indentation guides
indentation guides
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: Formatting & Indentation
8.0
All All
: P1 with 45 votes (vote)
: 8.0
Assigned To: Milutin Kristofic
issues@editor
:
: 203545 206329 239537 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-03-22 17:28 UTC by jean-francois
Modified: 2014-05-17 11:28 UTC (History)
14 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
example of identation guide in Notepad2 (27.85 KB, image/png)
2010-08-04 14:21 UTC, ericc
Details
proposed patch (3.31 KB, patch)
2014-01-08 18:35 UTC, Alexander Simon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jean-francois 2010-03-22 17:28:18 UTC
it would be nice to have a way to show indentation guides, like in some other editors like scite or notepad++.
Please find here screenshots of the feature in scite :
http://img263.imageshack.us/img263/4958/indentguides1.png
http://img716.imageshack.us/img716/3683/indentguides2.png
Comment 1 ericc 2010-08-04 14:21:33 UTC
Created attachment 101196 [details]
example of identation guide in Notepad2
Comment 2 ericc 2010-08-04 14:24:51 UTC
I need also this feature. 
I think it could be easy to implement and it can help a lot (me at least ;) ) to write a better code.

It's a little bit annoying (and ridiculous) when you have a large file and you detect an error (a missing closing tag by example) thank to indentation to be obliged to reopen it in an external editor just to better see where is the problem ... 

Thanks in advance
Comment 3 fabiochelly 2010-11-04 10:05:20 UTC
I used to work with SciTE and I really miss this functionality in Netbeans.
Especially in Python where indentation is essential (I use Netbeans for PHP and Python).

I think that indentation guides would give Netbeans a real advantage compared to its competitors.
Comment 4 schpinn 2010-12-14 11:12:12 UTC
I agree. This is the only thing that's keeping NetBeans to be the most awesome and feature full editor currently available. I'd kill for this feature. Wouldn't mind donating something if that would make it happen faster.
Comment 5 schpinn 2011-04-14 10:16:13 UTC
Any progress on this? This is the only thing keeping me from using NetBeans as my default IDE. I've gotten too used to this and can't get used to working without it.
Comment 6 ggaudrea 2011-08-24 00:40:32 UTC
Yes, please add this to a future release. It's hard to make sure everything is properly indented if you can't see vertical guides.
Comment 7 encodes 2011-11-30 10:32:46 UTC
would be most useful this feature.

many other editors offer this functionality.
Comment 8 undead 2011-12-25 14:35:13 UTC
hey.. is there any news about this enhancement?
Comment 9 Meijuh 2012-01-06 15:34:12 UTC
Please give priority to this issue it would be a great improvement to netbeans.
Comment 10 monk.e.boy 2012-01-06 16:06:34 UTC
*** Bug 206329 has been marked as a duplicate of this bug. ***
Comment 11 ecurbh 2012-01-11 17:25:26 UTC
Please add this feature. It is the one and only thing I truly miss from my previous IDE.
Comment 12 Alexander Kouznetsov 2012-02-28 01:18:25 UTC
This is really necessary thing sometimes. I vote for it.
Comment 13 wusluf 2012-07-06 15:43:45 UTC
I'm truly missing this function.
additionally coloured guides would be awesome.

http://img194.imageshack.us/img194/3428/screenshotfrom201207061.png

you can get these with JEdit and the Candy Folds plugin.
In the end I would be really happy to adjust:
1. colour
2. style of guide (doted, fuzzy,...)
3. thickness
so you can distinguish a long loop from an if clause at a glance.
Comment 14 dc2005 2012-08-22 13:19:15 UTC
I think this would be a great addition to netbeans, this seems to be the missing piece to a perfect IDE.

it just makes things so much easier when coding and trying to keep your code formatted nicely.

would be nice to see on 7.2, but I'll make a guess it'll be added to 7.3 if its accepted by the developers.
Comment 15 markiewb 2012-09-22 23:25:03 UTC
*** Bug 203545 has been marked as a duplicate of this bug. ***
Comment 16 stormherz 2012-12-01 19:42:56 UTC
great feature, makes code look more structured
Comment 17 capaj 2012-12-11 07:43:15 UTC
Please add this! This is small thing which makes a world of difference!
Comment 18 blakeb 2012-12-14 16:04:15 UTC
Please add this feature! I would love to see this in future releases.
Comment 19 Lord-Vader 2013-02-01 21:03:31 UTC
Also wants/need  indentation guides in netbeans
I think is a really really usefull feature, Thanks
Comment 20 bugmenot1 2013-02-20 23:19:22 UTC
Would absolutely love this. Every program focused on any kind of code editing should have this built in. Unfortunately, Netbeans and Eclipse don't have it... :(
Comment 21 Alxv 2013-02-24 11:46:30 UTC
I think this is easy to implement and very usefull feature (source codes will become more readable). Please add it.
Comment 22 abdel.bolanos 2013-03-01 16:01:06 UTC
Yes please, is so useful. I should not be so hard and is so good to have.
Comment 23 Shedimanos 2013-09-06 07:16:10 UTC
Add this feature please
Comment 24 cebrax 2013-11-04 11:10:13 UTC
Please add this feature, please, please, please!
Comment 25 Milutin Kristofic 2013-11-18 13:00:37 UTC
http://hg.netbeans.org/jet-main/rev/52536ddbf105
Comment 26 Quality Engineering 2013-11-24 02:20:05 UTC
Integrated into 'main-silver', will be available in build *201311240002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/52536ddbf105
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #182513 - indentation guides
Comment 27 Alexander Simon 2013-12-16 21:13:42 UTC
It seems the fix has wrong algorithm for calculating indent size.
The fix uses:
indentLevelSize = prefs.getInt(SimpleValueNames.SPACES_PER_TAB, EditorPreferencesDefaults.defaultSpacesPerTab);
Should be:
indentLevelSize = prefs.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, EditorPreferencesDefaults.defaultSpacesPerTab);

Also suspicious code:
            if (propName == null || SimpleValueNames.SPACES_PER_TAB.equals(propName)) {
                releaseChildren = true;
                Integer indentLevelInteger = (Integer) docView.getDocument().getProperty(SimpleValueNames.SPACES_PER_TAB);
                indentLevelSize = (indentLevelInteger != null) ? indentLevelInteger : indentLevelSize;
            }
Comment 28 Milutin Kristofic 2013-12-17 13:47:35 UTC
Alexander, in formatting options space_per_tab is called "Number of Spaces per Indent". Space_per_tab is old name, it should be renamed, but it has right value (default: 4) that I needed.
Comment 29 Alexander Simon 2013-12-17 14:01:40 UTC
(In reply to Milutin Kristofic from comment #28)
> Alexander, in formatting options space_per_tab is called "Number of Spaces
> per Indent". Space_per_tab is old name, it should be renamed, but it has
> right value (default: 4) that I needed.
See java doc in class SimpleValueNames:

/**
 * How many spaces substitute per one typed tab. This parameter has
 * effect only when EXPAND_TABS setting is set to true.
 * This parameter has no influence on how
 * the existing tabs are displayed.
 * Values: java.lang.Integer instances
 */
public static final String SPACES_PER_TAB = "spaces-per-tab";

/**
 * Shift-width says how many spaces should the formatter use
 * to indent the more inner level of code. This setting is independent of <tt>TAB_SIZE</tt>
 * and <tt>SPACES_PER_TAB</tt>.
 * Values: java.lang.Integer instances
 */
public static final String INDENT_SHIFT_WIDTH = "indent-shift-width";

According to this API C/C++ uses INDENT_SHIFT_WIDTH for indent size.

See also:
org.netbeans.api.java.source.CodeStyle:

public int getIndentSize() {
  int indentLevel = preferences.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, getDefaultAsInt(indentSize));
  if (indentLevel <= 0) {
    boolean expandTabs = preferences.getBoolean(SimpleValueNames.EXPAND_TABS, getDefaultAsBoolean(expandTabToSpaces));
    if (expandTabs) {
      indentLevel = preferences.getInt(SimpleValueNames.SPACES_PER_TAB, getDefaultAsInt(spacesPerTab));
    } else {
      indentLevel = preferences.getInt(SimpleValueNames.TAB_SIZE, getDefaultAsInt(tabSize));
    }
  }
  return indentLevel;
}
Comment 30 Milutin Kristofic 2013-12-17 14:54:43 UTC
Ok, thank you Alexander. I will look at it and fix it.
Comment 31 Milutin Kristofic 2014-01-07 14:33:12 UTC
Alexander, your suggestion is pushed to jet-main http://hg.netbeans.org/jet-main/rev/f88bed57f43c
Comment 32 Alexander Simon 2014-01-08 18:18:48 UTC
(In reply to Milutin Kristofic from comment #31)
> Alexander, your suggestion is pushed to jet-main
> http://hg.netbeans.org/jet-main/rev/f88bed57f43c

The fix does not work for C/C++.
The property is null:
docView.getDocument().getProperty(SimpleValueNames.INDENT_SHIFT_WIDTH)
The indent size is:
prefs.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, 0);

As result the method getIndentSize() returns tab size instead of indent size.

It seems the method getIndentSize() should reorder properties:
1.docView.getDocument().getProperty(SimpleValueNames.INDENT_SHIFT_WIDTH)
2.prefs.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, 0)
3.docView.getDocument().getProperty(SimpleValueNames.EXPAND_TABS)
4.prefs.getBoolean(SimpleValueNames.EXPAND_TABS, EditorPreferencesDefaults.defaultExpandTabs)
... and so on
Comment 33 Alexander Simon 2014-01-08 18:35:23 UTC
Created attachment 143727 [details]
proposed patch
Comment 34 Milutin Kristofic 2014-01-09 11:45:18 UTC
Ok, my thought process was, if somebody is pushing some values to document, they have for him higher priority than values in prefs. My example is preview window in settings, where I give values in combobox. Why C/C++ has tab_size in properties but not indent_shift_width? But, ok, I make a change you suggested.
Comment 35 Alexander Simon 2014-01-09 13:19:55 UTC
(In reply to Milutin Kristofic from comment #34)
> Ok, my thought process was, if somebody is pushing some values to document,
> they have for him higher priority than values in prefs.
Yes you are right, but your commit violated it for INDENT_SHIFT_WIDTH.

> Why C/C++ has > tab_size in properties but not indent_shift_width?
I do not sure that C/C++ responsible for putting tab_size in the doc properties.
It seems BaseDocument.init() do it. See 538 line.
IMHO it is legacy code.
Comment 36 Milutin Kristofic 2014-01-09 14:44:32 UTC
Thank you Alexander, I push your proposed patch. http://hg.netbeans.org/jet-main/rev/96a753902969
Comment 37 Dusan Balek 2014-01-15 15:33:29 UTC
*** Bug 239537 has been marked as a duplicate of this bug. ***
Comment 38 gwaldon 2014-05-17 04:07:12 UTC
Definitively a lack of courtesy toward the few who are using the editor in a non-programming platform and a real pain to go through multiple MIME types to remove them. Can we get this enabled false by default?

DocumentViewOp line 927:
boolean currentGuideLinesEnable = Boolean.TRUE.equals(prefs.getBoolean("enable.guide.lines", false);

Or maybe a kill switch in the conf file? We have already -J-Dorg.netbeans.editor.linewrap; why not -J-Dorg.netbeans.editor.indentguide
Comment 39 markiewb 2014-05-17 11:28:35 UTC
@gwaldon: Please do not reopen an issue for an already released NetBeans version!

Instead create a new issue and refer in the new one a link to the original issue.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo