Re #1: I will dash your hopes. :-)
I’ve been thinking about writing a plugin to manage indentation, because so far
nothing I’ve seen does it right.
I prefer tabs for indentation. Why? because I don’t want it to be possible to
have the cursor anywhere but a valid indent level prior to the actual code on
the line. I want to be able to set the tab width to what I like and have
everyone else’s code adapt, without modifying the file content. When spaces
are used to indent, that doesn’t work.
Tabs must only be the first characters on the line. After the first non-tab
there can never be another tab on the line. This rule ensures that it is
possible to change the tab width to any positive integer and not screw up any
intentional alignment.
I want to use spaces after the tabs for alignment purposes, e.g lining up
parameters so they appear after the ‘(‘ if a method call needs to split lines.
method(a ,b
c ,d);
<tab to here, spaces to align ‘c’ with ‘a'
int one = 1;
int three = 3;
int five = 5
<always spaces to align after indent level
I want code formatting to respect intentional extra spaces for alignment.
I could tolerate spaces if they weren’t so painful for navigation. I want
everything treated as a tab up to the indent level (based on the program
structure).
Maybe an advanced plugin could keep track of indent level separately so the
editor behaved as if tabs were used to indent, but was smart about what was
detected as the indent width in the file when it was loaded. IT could treat
indenting as if it were done with tabs. When saving it would know that the
file used spaces and it knows how many spaces were used to indent one level so
keeps that number of spaces when the file is saved, regardless of what my
preferred tab width is for viewing/editing.
If spaces are found before tabs on the same line, the plugin could use version
control to find who last committed the file, track them down on social media,
and send a firing squad to their house ;-)
Scott
P.S. A NetBeans option to make whitespace visible so we can see when
spaces/tabs are not used consistently would be nice.
> On Dec 10, 2019, at 2:08 PM, Laszlo Kishalmi <[email protected]>
> wrote:
>
> Well I'd:
>
> 1. convert tab to spaces (however I hope no one using tabs by now)
> 2. Create a histogram from the leading spaces
> 3. Start some division test.
> Let say we test with indent: IND
> for each all leading space number in the histogram with IND then multiple
> the remainder with the number of lines which that leading space is used that
> would be DEV
> summarize of these DEV values (deviations)
>
> The deviation for IND=1 shall be 0. Start to increase IND, the largest number
> while IND is 0 the indent of the file.
>
> For miss formatted files you might allow a threshold somewhat above 0 as
> well. This threshold could be a function of the number of lines in the file.
>
> On 12/10/19 10:50 AM, Emilian Bold wrote:
>> Well, this is some original idea! If somebody needs help with such a
>> thing, I would do it just to learn.
>>
>> But honestly for an existing file I believe you could detect the
>> indentation style just looking at the AST. Heuristics would work imho.
>> But, of course, a neural network would be the cool way of solving it.
>>
>> --emi
>>
>> On Tue, Dec 10, 2019 at 8:44 PM Siddhesh Rane <[email protected]>
>> wrote:
>>> Glad to see someone interested in this feature.
>>> A long time ago I came across a blog post[1] by Andrej Karpathy (AI guru)
>>> in which a neural network was trained on variety of text datasets and then
>>> used as a content generator. When trained on Linux and Apache source code,
>>> the generator could reproduce pseudo code, that was not valid code, but was
>>> very well formatted. It was quite cool to see the network had learned
>>> several things, indentation being one of them. Do check out the Source Code
>>> section of the blog to know what I am talking about.
>>>
>>> The most straightforward way I see to do this is some frequency model of a
>>> predefined set of indentation rules.
>>> But if anyone is interested to create a small fast neural network with
>>> limited features, it would be great to see the possibilities.
>>>
>>> +1 for this.
>>>
>>> Regards
>>> Siddhesh
>>>
>>> [1] http://karpathy.github.io/2015/05/21/rnn-effectiveness/
>>>
>>> December 10, 2019 11:16 PM, "Alvin Thompson" <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> Assuming that this email doesn't get flagged as spam due to the subject
>>>> line, this is just a
>>>> reminder that I have a bounty for anyone who creates a NetBeans plugin
>>>> that detects and uses the
>>>> existing indentation of the file being edited. For any indentation info
>>>> that can not be gleaned
>>>> from the file, it should fall back to the preferences. This really is an
>>>> absolute must team work
>>>> these days.
>>>>
>>>> You get $100 for coming up with the plugin, and another $100 if it gets
>>>> donated and makes it into
>>>> NetBeans itself. But I imagine most people will want to do this so that I
>>>> have a slightly higher
>>>> opinion of them.
>>>>
>>>> I would do this myself but I am very, very lazy.
>>>>
>>>> That is all,
>>>> Alvin
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>> For further information about the NetBeans mailing lists, visit:
>>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>> For further information about the NetBeans mailing lists, visit:
>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists