I started by suggesting you use the first part of the example command you included since it does what you want but it's totally broken as far as I can tell...certainly it's not compatible with your format. So let's see what we can do.
How would you accomplish the same thing manually if the cursor was somewhere on the line you want to "check"? This is one way:
0 :: Move cursor to the beginning of the line.
2f :: Go forward to the second occurrence of Space
rx :: Change the character under the cursor to 'x'.
These are all done while in "Normal mode". How do we create mappings that are available in Normal mode? With
:nmap. Or, more precisely, with this variation of that command:
:nnoremap (see paragraph under
:h :nnoremap for explanation)...
:nnoremap \x 02f rx
That's it. Or not. It would be nice to do nothing if there's already a 'x' in the column...or if we're not even on an item type of line...
So here's a better command:
:s/^- \[\zs /x/
This is a substituion that replaces the character in the "check" column with
x...but only if there's a space there. Otherwise it does nothing.
The pattern is a little mysterious so here's a breakdown:
^ :: match the beginning of the line
- \[ :: eat up the three characters that start an item
\zs :: this says that we don't actually do substitution against characters that have been matched before this point
:: match a space
Mapping it, again with
:nnoremap, we just need to "hit Enter" (
<CR>) at the end...
:nnoremap \x :s/^- \[\zs /x/<CR>
For good measure, here's a mapping to do the reverse ("un-check" an item):
:nnoremap \o :s/^- \[\zsx/ /<CR>
You can, of course, use whatever unassigned keys you want in place of