helix icon indicating copy to clipboard operation
helix copied to clipboard

Support for block comments

Open k2d222 opened this issue 3 years ago • 2 comments

Add support for block comments. (line comment support per language was added in #463)

There are multiple use-cases for this:

  • Many languages don't support line comments but do support block comments, e.g. html/xml, css, old c, ocaml. the toggle_comments command could fallback to a multi-line comment.
  • Some users / codebases prefer line comments. That preference could be set in languages.toml.
  • A comment textobject could be interesting too, to select whole comments or comment out selections.

k2d222 avatar Jan 13 '22 18:01 k2d222

On a related note - I won't make a new issue for this:

The :reflow command can reformat a selected part of a C block comment of the following style (in my limited testing), but unlike Vim, adding a newline while editing the comment will not add * at the line start, which is rather tedious.

/*
 * foo
 * bar
 */

(this was tested in a .h file with clangd configured as LSP and .h added as a C language extension)

mikkelfj avatar Nov 05 '22 15:11 mikkelfj

That's https://github.com/helix-editor/helix/issues/1730

the-mikedavis avatar Nov 05 '22 15:11 the-mikedavis

Is there currently no way to toggle comments in languages like CSS, HTML? I'm (currently) not even talking about having separate shortcuts for block comments, would just be nice if it worked at all in such languages.

Elias-Graf avatar Nov 10 '22 21:11 Elias-Graf

Correct, this issue covers adding support for toggling block comments

the-mikedavis avatar Nov 10 '22 23:11 the-mikedavis

this could be potentially fixed with #4718: heres a video of it in action, its still a draft though and needs a bit of work

gabydd avatar Nov 11 '22 23:11 gabydd

Hi guys! I'm in love with Helix. While I'm learning to program in C, I wrote a commenting utility for Helix. For those who interested, here is the link to the repo.

b52es avatar Nov 27 '23 14:11 b52es