53

Is there a way to highlight a section of code to be commented out in one swoop using geany text editor?

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
Spencer Cooley
  • 8,471
  • 16
  • 48
  • 63

3 Answers3

76

Control-E to toggle commenting.

ishmael
  • 1,796
  • 3
  • 18
  • 19
  • 8
    Why does geany use `#~` for comments in bash instead of just `#`? – a06e Mar 24 '15 at 12:49
  • 6
    @becko: In fact it inserts three characters `#~ `. The last one is a space. I think the reason is to allow Geany to detect its own comments to be able to remove them when uncommenting and not to touch comments created different ways. – pabouk - Ukraine stay strong May 26 '15 at 12:22
  • 14
    @becko: You can turn that off under "Comment toggle marker" in Preferences (I prefer setting it to a single space). – geira Jul 08 '15 at 10:09
  • @becko, it is in preferences -> editor -> functions. I want to have `# ` (with space) but this does not work. Leaving empty the input will result to `#` which is not the standard commenting. – Timo Jan 25 '21 at 15:28
  • In version 1.37.1, I don't understand why Geany has shortcuts displayed in the menus for just about everything except "commenting and un-commenting". This control-E shotcut doesn't act the same as the `Edit > Format > Comment Line(s)` (which doesn't insert that `~`). – Lonnie Best Jun 24 '22 at 15:14
6

Control + E

Edit default comment: Preferences > Editor > Features > Comment toggle marker

Chris
  • 89
  • 1
  • 8
6

Yes there is, you just have to highlight the code you want to comment then right-click, mouse over format and and click on "Comment Line(s)" to comment the lines. To uncomment,instead of selecting "Comment Line(s)" select "Uncomment Line(s)".

CupOfTea
  • 271
  • 2
  • 12