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.