Whole statusline color-modes and toggle markdown - [ ] as fast as possible #9970
Unanswered
adriangalilea
asked this question in
Q&A
Replies: 1 comment
-
Here's what I came up with for toggling or creating checkboxes in markdown (it's not perfect but works well enough). [keys.normal.space]
"t" = [
# Extend the selection to include the whole line (or lines),
# without selecting an extra line when a single line is selected
"extend_to_line_start",
"flip_selections",
"extend_to_line_end",
"extend_line",
# Run the selection through awk
# - Toggle '- [ ]' to '- [x]' and vice-versa
# - If the line starts with a '-' bullet, then add an empty checkbox
# - If the line isn't a bullet point, then add '- [ ] '
""":pipe awk '{
if ($0 ~ /^- \\[ \\]/) {
sub(/^- \\[ \\]/, \"- [x]\"); print;
} else if ($0 ~ /^- \\[x\\]/) {
sub(/^- \\[x\\]/, \"- [ ]\"); print;
} else if ($0 ~ /^- /) {
sub(/^- /, \"- [ ] \"); print;
} else {
print \"- [ ] \" $0;
}
}'
""",
# Move the cursor to the start of the line and collapse the selection
# (this is the only way I've found to have consistent behaviour between
# single and multi-line toggling).
"goto_first_nonwhitespace",
"collapse_selection"
]
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Is it possible to set
color-modes
so that it lits up the whole statusline?If not, can I create multiple statuslines?
What would be the fastest way to toggle a markdown
- [ ]
checklist item?I was thinking about macros, but afaik they are not preserved, also was thinking about a custom keys.normal or something but not sure how to do it,
C-t = ["goto_first_nonwhitespace"]
but I don't know how to proceed from there 😄Beta Was this translation helpful? Give feedback.
All reactions