IDE scripting, add comment on any line

hi,

I have a script from the examples how to add a header comment, works great. Now I would like to position the cursor on a line and add a comment.
Can I do it ? and how ?
thanks

Not IDE scripting, but if you want to comment a line (or lines) that is currently selected using a hotkey, that is available:
macOS: Cmd+'
Windows/Linux: Ctrl+'

1 Like

thanks Anthony,
nobody cares about comments, it’s a pity that easy useful things are never working, what else can’t IDE scripting do ? sorry

:thinking: Are you asking, how to set an already existing text line(s) as a comment? (That is what Anthony understood)

Or how to ADD a NEW line of commented text?

what I would like to do is, put the cursor on a line, anywhere in the script and have some comment lines inserted, the same as the script does with the header comment which are always go on top of the script.
but don’t tell me I should copy and paste …

sorry if there was a misunderstanding

You could get the source, split on line endings, insert lines where you want them, join back to a string and then set the source.

thanks Greg,
t sounds easy to do, but I have no degree in IDE scripting so it’s not an option for me.
I bet there are more developers around who would like to have such a tool, to insert some lines of pre defined comment lines ( or code ) at the cursor position, or I’m the only one who uses comments in the source code ?
next Christmas is almost around the corner … Xojo let’s do it … shoudn’t take to long … would be nice …
just a suggestion to help to improve Xojo

thanks to all !!

IDE scripts use the same Xojo language you are already familiar with.

Var lines() as String = Split(Text, EndOfLine)
Lines.AddRowAt(5, "// hello world")
Text = join(lines, EndOfLine)

Just create a new script from the file menu.

1 Like

thanks so much Greg, that’s exactly what I was after, big help.

Something else: is is possible to run that script from a hot key ?
would be nice,

found the hot key setting …

thanks again.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.