vimtex icon indicating copy to clipboard operation
vimtex copied to clipboard

New function to toggle `\\`

Open handcart2034 opened this issue 9 months ago • 1 comments

Hi, this is a new function that toggles \\ at line end. In environments like align, sometimes the formulas are changed thus the line break is not optimal. One needs $ or A to move to end of line, then either xx or \\, finally go back to the original position, which can be quite tiring for more than a couple lines.

So wrote this function and map tsb to it. If everything looks good will add tests and docs to finalize this request.

handcart2034 avatar May 05 '24 16:05 handcart2034

Hi, this is a new function that toggles \\ at line end. In environments like align, sometimes the formulas are changed thus the line break is not optimal. One needs $ or A to move to end of line, then either xx or \\, finally go back to the original position, which can be quite tiring for more than a couple lines.

I don't mind adding this, even though I don't think I'll end up using it. It falls nicely into the current patterns and shouldn't be "in the way" of anything that I can think of. I had a comment the implementation, see above.

So wrote this function and map tsb to it. If everything looks good will add tests and docs to finalize this request.

I think it looks good, although I would prefer if you made the suggested change. And, of course, that you add a couple of tests and docs.

And thanks! I appreciate the effort you've made here in actually implementing the feature you want added!

lervag avatar May 08 '24 18:05 lervag

Thanks for the suggestions and the RegEx simplification, all of them have been implemented, along with a couple tests and document updates.

handcart2034 avatar May 12 '24 22:05 handcart2034

Thanks! I made a minor additional change and then merged this now. The change was basically to change "Toggle line end \\" to "Toggle line-break macro \\" and to use this name consistently.

lervag avatar May 13 '24 17:05 lervag

Note, though: I rebased and merged locally; for some reason, Github doesn't recognize this.

lervag avatar May 13 '24 17:05 lervag

Neat! Small follow-up suggestion: support for visual mode ;)

clason avatar May 13 '24 18:05 clason

Heh, yes. @handcart2034 are you up for the challenge? One way to implement it would be to reuse the current implementation and just apply it to every line in the visual selection.

lervag avatar May 13 '24 20:05 lervag