Align inline comments to a certain column

Snywrtne
Posts: 1
Joined: 14.10.2023 15:56

Align inline comments to a certain column

Post by Snywrtne »

Hi,
i often use inline comments at the end of the code line (i.e. at column 80, or a column mark made with the Plugin "Column Mark").
I'm looking for a way to align the comments in an easy manner to such a fixed column as is showed in that link:
https://stackoverflow.com/questions/581 ... -in-vscode
Can anybody give me a tip to achieve that.
Thanks in advance, Josef
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

to change any content, you must use plugin CudaFormatter with proper formatter-subplugin.

8 CudaFormatter
8.1 CudaFormatter commands
8.2 How to run formatter ESLint on saving
8.3 How formatter can know filename
https://wiki.freepascal.org/CudaText_plugins

so you need the 'formatter' whcih aligns comments to column e.g. 80.
not hard to make it.
this formatter can be written fast, e.g. for C / C++:

- take a line
- parse it to find inline comment (skip // chars inside strings, and skip multi-line comments)
- align comment

examples of formatters:
https://sourceforge.net/projects/cudate ... ormatters/
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

to parse a line to find comments, trick may be used.

- find '//' in line (it can be inside string too)
- check that '//' forms the real inline comment using Cud's API https://wiki.freepascal.org/CudaText_AP ... .get_token

'formatters' don't use this API, so it may be a simple plugin instead of 'formatter'. plugin which changes the current document.
Layerprogg
Posts: 10
Joined: 15.04.2015 15:37

Re: Align inline comments to a certain column

Post by Layerprogg »

Thank you for the suggestions.
I'll try, although I'm not the great programmer.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

i can write the plugin for you. if you write a good review about Cud on some site.
Layerprogg
Posts: 10
Joined: 15.04.2015 15:37

Re: Align inline comments to a certain column

Post by Layerprogg »

Review is a problem for me, i can make a donation. Let me say 50 EUR.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

donation is not needed, thanks.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

what you can do: write the 'request for plugin' here
https://github.com/Alexey-T/CudaText/issues
with the reward for ready plugin, 30$ is enough.
Layerprogg
Posts: 10
Joined: 15.04.2015 15:37

Re: Align inline comments to a certain column

Post by Layerprogg »

Hi Alexey, as i noticed donation is buying a license of "Universal Viewer". I just bought a license, (order number: 29674694)
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Align inline comments to a certain column

Post by main Alexey »

Thanks, I got the UVPro program buying, so I will help you.
Post Reply