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@beehaw.orgOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      8 months ago

      Is it a bug?

      Or user error?

      How could a text editor not have this feature?

      Or am i editing wrong?

      • magikmw@lemm.ee
        link
        fedilink
        arrow-up
        0
        ·
        8 months ago

        You wont know unless you fill a bug report and maintainers get around to triage it.

        • crank@beehaw.orgOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          8 months ago

          I mean in theory someone else might know the answer… I don’t want to bother the developers with every little problem. They are already busy making the software. I try to treat the developers with respect by reaching out to others for something like this. I do not know if there is a problem with the application. If someone else who uses the software would mention if they have this problem, or a different work style, or make a workaround. Possibly running the text through a script could do it? Maybe it is buried in one of the ambiguously named plugins.