Does anyone like .*-insert hooks inserting comments?

These hooks typically copy any comment prefix from a previous line. More often than not, I don’t want to copy comment prefixes.
One workaround is to press <ret> twice but I found that hard to get used to that, plus it breaks a valid use case.

I can see that the hooks are useful in theory when writing several hard-wrapped comment lines in a row, but when I do that I always end up rewriting something in the middle, and need to reflow the paragraph anyway, so the hooks are more of a liability. Instead, I use this script to reflow a paragraph while keeping a comment prefix like // or //!.

input=$(cat; echo .)
prefix=$(printf %s "$input" | perl -ne 'if (m{^\h*((?://[!/]?|#|>(?: >)*) )}) {print $1; exit}' )
printf %s "$input" | fmt --prefix="$prefix" "$@"

Overall, I think the .*-insert hooks don’t add significant value and make the editor less predictable.
I have disabled them via disabled_hooks but I think we should disable them by default (perhaps move them to an external plugin).
Since there are already some breaking changes in the breaking-cleanups branch, this seems is an opportune time.
What do people think? Am I missing something?

I do like the c-family.kak’s abilty to continue multiline comments (/* with *) that’s probably worth keeping.

I think many people probably have a preference about which comment implementations they want to keep and which they would prefer to remove, just as you do. Given that it’s trivial to disable them all, and far more difficult for a user to discover they exist, I personally think they should remain on by default. For the record I also dislike them for the most part.

1 Like

If there’s no decent formatting tool for a language or file format then /not/ having some kind of formatting can end up being a massive pain - I wrote the current shell formatting code because the lack was making me want to stop using kak sometimes. As written it’s far from perfect, and has some irritating behaviours, but it’s better than not having anything (in my opinion - ymmv)

Personally I find comment continuation useful in shell and have found it very annoying when it’s /not/ there (as is the case with sql, for which I haven’t been able to find a formatting tool I like). Given my experiences I’d rather the functionality stayed, particularly given it’s not hard to disable. At least, until there are good formatting tools for every language anyone cares about . . .

I find the automatic insertion of leading comment characters like # annoying for the same reasons as you point out.

Most of the time I find it useful, there are some other moments where it is anoying but the former wins imo.

Typically I’m writing code and then going back and commenting afterwards. The hooks are nice then.

But it is annoying when you go back and edit code with comments/edited out code and I’ve never been annoyed by another editor not having this feature.

I put this in a similar category as auto-closing parens/quotes. I don’t care if it’s there or not because the effort it saves you is minimal and you only notice it when it does something you don’t want, so the experience is overall negative.

1 Like

what about picking a family of hooks for an insert session? like when one uses \ for no-hooks