Align inline comments to a certain column

main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

I will try to code this in the nearest N (<9) days.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

I made first version of the command.
Plugin CudaExt - my fork. command is here: "Plugins / CudaExt / Align / Align line-comments to a certain column".
To try it:

- remove CudaExt plugin if it's installed
- get my fork: "Plugins / Addons Manager / Install from Git", enter URL https://github.com/CudaText-addons/cuda_ext
- restart Cud

Please test.
Layerprogg
Posts: 10
Joined: 15.04.2015 15:37

Re: Align inline comments to a certain column

Post by Layerprogg »

Hi Alexey, works!
But there should be a treshold value for the algorithm.
All existing comments left of that threshold value should be ignored.

Example:
I often use a little comment at the end of a switch command to better identify the ending parenthesis.
I don't want this comment to be aligned with the pluging at i.e. column 80.
switch(cond) {
case 'ch':
break;

case nr:
break;

default: break;
} // switch
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

hmm, how plugin can detect "this comment is not to change"? e.g. "} // switch" line - what is special for this line for plugin? how to detect all such lines "to not touch"?
Layerprogg
Posts: 10
Joined: 15.04.2015 15:37

Re: Align inline comments to a certain column

Post by Layerprogg »

Perhaps i didn't say it clear enough.
For me there are two numbers of interest:
1st: the column number to which the comments should be aligned.
2nd: a column number that says: ignore this line if a comment starts to the left of this column.
For my example this means: Align all comments to column 80 but ignore the line if there is a comment beginning left of i.e. column 40
best regards
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

okay. I updated the Git repo on github. changed to the prompt to ask for 2 options, 2nd option is "minimal allowed column of comment".
Layerprogg
Posts: 10
Joined: 15.04.2015 15:37

Re: Align inline comments to a certain column

Post by Layerprogg »

Hurray, that's it. Thank you very much
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

todo for this command: support e.g. PHP lexer (currently PHP lexer blocks the code to work).
Post Reply