Manual-Indent v Auto-Indent v Smart-Indent
-
Didn’t know NP++ has smart indent. Smart indent is rather language specific.
Maybe it is a new feature but are you sure it is not some plugin that adds this “smartness”? -
@gstavi said in Manual-Indent v Auto-Indent v Smart-Indent:
Didn’t know NP++ has smart indent.
N++ has smart-indent for certain languages (mainly the C family, and in 8.6.8 it has been added for Python). If auto-indent is on, then you get smart-indent for languages that “have the smarts”.
@Agung-Sukma said in Manual-Indent v Auto-Indent v Smart-Indent:
I want auto-indent, not smart-indent, how?
There is currently no way to achieve this.
See discussion comments in https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15396. -
This “smart indent” as only option was a really poor choice.
Continuing the trend of granting “random” user requests without thinking about product coherency.The good thing about block indent is that it is simple and completely predictable.
Users experience with it for 2 minutes and from that point know exactly what the behavior will be.Smart indent is unpredictable. Users will never know what to expect until they experienced ALL the syntax combinations that were programmed into it. And they will hardly ever be satisfied since each user has a slightly different view of the right style that the smart indent should follow. Products that focus on smart indent (and auto code “beautifiers”) tend to give users ton of options to configure.
-
@gstavi said in Manual-Indent v Auto-Indent v Smart-Indent:
And they will hardly ever be satisfied since each user has a slightly different view of the right style that the smart indent should follow.
This is seemingly very true for C-like languages, although I don’t recall too many complaints with what Notepad++ does in this regard.
Python is much simpler, in this regard, and Notepad++ should benefit from having smart indent with it.
-
@Alan-Kilborn said in Manual-Indent v Auto-Indent v Smart-Indent:
This is seemingly very true for C-like languages, although I don’t recall too many complaints with what Notepad++ does in this regard.
What drives me up a tree is what happens with plain text files (though it can affect languages, too).
In plain text, if you have auto-indent enabled, and you press enter at the end of a line that begins with white space, the next line is indented to match. That can save a lot of typing… except…
FFS, if all it is doing is matching the indent of the previous line to start the new line, why doesn’t it just copy the characters used to create that indent in the previous line? It will use tabs or spaces depending on what is set in Settings | Preferences… | Language: Indent Settings: Indent using, completely ignoring the context.
Well, I know why… because it uses SCI_SETLINEINDENTATION to accomplish the indentation… but it is really annoying.
I have it on my mental list either to add to my plugin, or to create a separate plugin, to change this behavior so it will just copy the previous line when the indentation is not changing, and when creating new indentation (in files that have a language definition), scan nearby lines to decide whether to use tabs or spaces. If it works, it could serve as a model for a request to make Notepad++ behave that way. If I get to work on that one day, I will certainly review this thread to see what other options might make sense.
-
@Alan-Kilborn said in Manual-Indent v Auto-Indent v Smart-Indent:
Python is much simpler, in this regard, and Notepad++ should benefit from having smart indent with it.
Agreed. Should I ever think about trying to program in Python, having that little smart indent working according to Python’s quirk of requiring it, would greatly facilitate someone not versed in using specific indentations to make a program work based on those indentations. At present, it is one of the main reasons I only use those learn Python apps…and never go past it. :-)
-
This post is deleted! -
@Coises said in Manual-Indent v Auto-Indent v Smart-Indent:
if all it is doing is matching the indent of the previous line to start the new line, why doesn’t it just copy the characters used to create that indent in the previous line? It will use tabs or spaces depending on what is set in Settings | Preferences… | Language: Indent Settings: Indent using, completely ignoring the context.
Everyone is different, of course, but for me, the current behavior in this regard is the way I want it. It sounds like maybe you are often in a situation of mixed tabs/spaces?
just copy the characters used to create that indent in the previous line?
This seems reasonable. At least for auto-indent that places the caret in the same column as the line above (non-smart auto-indent).
What should it do for smart auto-indent? What makes up that addition indentation? The setting choice from the Settings, or perhaps the tab/spaces just before, as shown below for a couple of cases, where Enter is pressed after
foo
, smart-indent takes place, and then user directly typesbar
:scan nearby lines to decide whether to use tabs or spaces
This seems like a problematic thing… what’s “nearby”?, what if nearby lines are not consistent?, …? This hints at @gstavi’s point about needing “tons of options to configure”.
-
@Alan-Kilborn said in Manual-Indent v Auto-Indent v Smart-Indent:
Everyone is different, of course, but for me, the current behavior in this regard is the way I want it. It sounds like maybe you are often in a situation of mixed tabs/spaces?
Not too often mixed within the same file, but from one file to the next, certainly. If it were a menu-accessible, per-tab setting, that wouldn’t be so bad. But every time a file differs from the previous file you were editing auto-indent “breaks” unless you open the Settings dialog, navigate to Language (not likely to be the first place an inexperienced user would look for tab-related settings) and change that setting.
Just to add to the crazy: If you’re using a language that is not set to use the default indent settings, when you open that dialog, [Default] is selected even though it is not in control; so either you look at it and it already says what you want, or you change it and nothing happens, and you’re confused; because you have to know, and remember, to select the active indent settings (which are not identified in any fashion) if those settings (which you don’t see until you select them) are not set to use the default.
By the way, Indent Settings: Indent using also affects what happens when you insert into virtual space in empty lines, and it affects pressing the tab key anywhere in the file (not just in indentation space). You lose the ability to type a tab at all when Space character(s) is selected, unless you discover (as I did only a few months ago) that SCI_TAB is a Scintilla command to which the Tab key is assigned, and you can clear that in Shortcut Mapper (then the Tab key will always insert a tab character). Until I realized that, I had to leave indentation to use tabs, because I use tab-delimited data often and it was crazy to type a tab and not get a tab. At least I finally found that.
What should it do for smart auto-indent? What makes up that addition indentation?
scan nearby lines to decide whether to use tabs or spaces
This seems like a problematic thing… what’s “nearby”?, what if nearby lines are not consistent?, …?
That’s the sort of problem doing this in a plug-in first might help to resolve — getting some practical experience before forcing it on everyone.
I haven’t seriously started to design this yet, but my thought is that “nearby lines“ means: first the line on which Enter was pressed (e.g., just before the new line), then one after, then one more before, then one more after, until you either hit a reasonable limit, hit both ends of the file, or find a (non-zero-length) line that begins with white space.
- If no line that begins with white space is found, use the settings.
- If the white space is all spaces, then use spaces.
- If the white space is all tabs, use tabs.
- If the white space is mixed:
- copy it exactly if the indentation is not changing.
- remove the last tab if the indentation is decreasing.
- follow the setting if indentation is increasing.
Of course the whole feature could be turned off for those who prefer the current behavior and find this too unpredictable.
Given the discussion in this thread, it seems an option to turn off syntax-aware indenting for any given language (or for all languages), thus making them all behave like plain text with regard to auto-indent, should also be an option.
-
@Coises said in Manual-Indent v Auto-Indent v Smart-Indent:
Not too often mixed within the same file, but from one file to the next, certainly. If it were a menu-accessible, per-tab setting, that wouldn’t be so bad.
There was a proposal recently on the github issues site concerning having the indent settings for the current file shown on the status bar, with the ability to click on it and adjust the settings for the current tab. Of course I can’t find this now; it may have been part of the discussion in the comments of the issue that is bringing us a three-pronged auto-indent setting.