this post was submitted on 11 Nov 2023
17 points (94.7% liked)

Linux

48216 readers
697 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

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.

you are viewing a single comment's thread
view the rest of the comments
[–] russjr08@outpost.zeuslink.net 2 points 1 year ago

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...