neorg icon indicating copy to clipboard operation
neorg copied to clipboard

Keybinding to remove task checkbox

Open celfred opened this issue 1 year ago • 4 comments

Issues

  • [X] I have checked existing issues and there are no existing ones with the same request.

Feature description

Hello,

I use task often using the keybindings : <localleader>ta (for Ambiguous) <localleader>td (for Done) I wish there was a new keybinding to remove the checkbox in case I eventually don't need it on the line. For example : <localleader>tD (capital D) to completely Delete the brackets (and what is inside) on the current line ?

Help

No

Implementation help

No response

celfred avatar Dec 29 '23 17:12 celfred

If this doesn't make it into core, or while you wait, you can create a keybind with the following substitution:

s/^\(\s*\(-\+\)\?\(\*\+\)\?\) (.)/\1/e which will remove the checkbox on the current line. That regex will also work for headers with a checkbox.

benlubas avatar Feb 07 '24 01:02 benlubas

Thanks a lot for your help. I have a little issue though. Your regexp works fine in itself, but trying to set a keymap, I get an error saying "Invalid escape sequence" ? If I get rid of all backslashes, the error disappears but the regexp no longer works :( Any idea ? [and sorry for novice level !]

Here's my invalid code : ` M.neorg = {

n = {

["<localleader>tD"] = { ":s/^\(\s*\(-\+\)\?\(\*\+\)\?\) (.)/\1/e", "Delete checkbox" },

},

} `

celfred avatar Feb 07 '24 07:02 celfred

You have to escape the backslashes (\ -> \\). Or, wrap the string with [[]] and not " to make it a raw string.

[[:s/^\(\s*\(-\+\)\?\(\*\+\)\?\) (.)/\1/e]]

And I think you need a <CR> at the end? I'm not sure tho.

pysan3 avatar Feb 07 '24 07:02 pysan3

@pysan3 Thanks a lot ! [[]] did the trick ! And yes, I've added <CR> at the end and it seems to work great ! Thanks also to @benlubas !

This will be very useful in my workflow :+1:

celfred avatar Feb 07 '24 10:02 celfred