Since Geany 2.0 has recently been released I decided to switch back to it from Kate. I used to like Geany but it had some problems I couldn’t quite remember.

So I quickly remembered the problem. I can’t figure out how to configure it to properly comment and comment blocks of code. Say you have the following in a file of type shell script:

	# a comment
	echo $variable

I want to be able to select the above lines and use a keybinding to comment them out, so the result would be:

	## a comment
	#echo $variable

Edit > Format > Comment Lines works as anticipated.

But if I decide I want the lines back, how do that with the same keybinding? Using Comment Lines again adds a second level of comments, which is what I would expect (but not what I want):

	### a comment
	##echo $variable

Edit > Format > Toggle Line Commentation works and the file returns to the original state. But if you reselect the original lines and run it again, you get

	 a comment
	#echo $variable

Which would obviously lead to unpredictable results.

There doesn’t seem to be a way for Geany to look at the block of text and decide whether it should be commented or uncommented and act accordingly.

Kate editor has this functionality in Selection > Toggle Comment as do other editors I’ve encountered. If there is a mix of commented and uncommented text, it will never remove comments. It only removes comments when the entire block has commenting, and then it removes only 1 level of comments. Perfect. Of course if you really want to force the matter, there are the more aggressive Comment and Uncomment.

Using the Geany Toggle Line Commentation leads to strange results, especially if you are starting with multiple levels of comments. Is there a way to duplicate the standard comment toggle in Geany? I tried to train myself to use Comment Line(s) and Uncomment Lines(s) instead of a single command but I just made a lot of mistakes where I didn’t realize there were multiple levels of comments or whatever and things became uncommented that shouldn’t have and it created a giant mess.

I’m not a professional IT person, just someone who enjoys text files in their spare time. I do a lot of commenting and uncommenting trying to find out how things work. I thought it was a pretty normal thing to do. There must be a way to do it right?

I recall digging around a bunch in the Geany repo/docs and it ended up that some problem I was having was a limitation of the Scintilla lexer and there wasn’t much Geany could do about it. But I am not sure if it was this issue or something else.

  •  crank   ( @crank@beehaw.org ) OP
    link
    fedilink
    English
    28 months ago

    Hi that is kind of you to reconsider. No offense taken or intended. :) It’s just that 3 people commented to tell me to make an issue as though asking a question about linux software was inappropriate. Whereas 0 people commented with anything about my question. I still wonder if I am doing commenting wrong somehow.

    I am pretty sure I opened some kind of issue with these folks in the past and it was closed because I couldn’t submit a PR. I thought it was some sort of policy but I can’t find anything about it; either I am misremembering or whatever I read before is gone.

    I really truly do not begrudge any devs for running their FLOSS projects how they feel is best for them. It takes all types to make up the world. I think on the whole it is better for the FLOSS community to be open to feedback even from those who aren’t able to provide a solution, in order that the needs of non-developers can be met. But when it comes to a project which is explicitly aimed at developers, idk what can I say? It’s probably better that people who prefer issues be in the form of PRs be creating tools for other developers rather than normy end users.

    • Plenty fair enough! I haven’t used Geany in a long time, and never actually ended up trying it as a code editor (rather than just the every once in a while one-off-quick-texr-editor) unfortunately, otherwise I’d have tried to answer your question directly.

      I do think that it’s alright to only accept PRs, just so long as it’s made a bit more clear. If I ever ran into a problem with Geany, I’d be completely unable to do anything as I have very little experience with C, let alone GTK and all of the other libraries along with it. I could learn right to effectively flip a few values or even maybe try to correct a basic logic issue - but that’s about it.

      That all being said, I hope someone is able to answer your question one way or another! Normally I’d recommend trying to reach out to the project’s chat since they usually have an IRC channel, Matrix channel, or some other place - but in this specific case after seeing the issues you mentioned I’d definitely be hesitant to do that sadly…