One disadvantage of creating a Vim mapping for
00 (in addition to the mapping for
0) is that, when you use the
0 motion, Vim will wait for the next key to tell whether what you wanted was
00, so using
0 on its own will feel awkward due to that delay. (This is generally an issue when creating mappings that have another valid mapping or keybinding as a prefix.)
One way to accomplish something like you want (pressing
0 twice to go to the true beginning) is to create a conditional mapping for the
0 key, which will go to the whitespace beginning of the line in the normal case, but that will instead jump to the true beginning of the line if the cursor is right after the initial indentation.
You can create such a mapping with:
nnoremap <expr> 0 virtcol('.') == indent('.')+1 ? '0' : '^'
xnoremap <expr> 0 virtcol('.') == indent('.')+1 ? '0' : '^'
onoremap <expr> 0 virtcol('.') == indent('.')+1 ? '0' : '^'
This will program the mapping in Normal (n), Visual (x) and Operator-Pending (o) modes. (Operator-Pending mode means you can use
c0 and Vim will use the mapping for the
Note that the way this expression is coded, Vim will "toggle" between the two possible beginnings of a line as you keep pressing
0, so if you're at the true beginning and press
0, you'll end up at the whitespace beginning. One possible drawback of this approach is that you might use
O by itself to go to the whitespace beginning of a line, but if you were already there, you'll end up at the true beginning instead, which makes the mapping somewhat counter intuitive in some cases.
You could change the mapping to always go to the whitespace beginning of a line whenever the cursor is somewhere past that column, then go to the true beginning whenever the cursor is before that column, that way pressing
0 more than twice will no longer toggle, but keep at the true beginning.
Another UX option would be to have the first use of
0 always go to the whitespace beginning of the line and repeated uses of
0 to then move to the true beginning of the line, but that's fairly more complex to program, since it's hard to detect what the last key used was. You might need to use a global variable to track whether you've just pressed
0 and then some autocommands tracking whether the cursor was moved and clear that global variable, in order to detect that another key or motion was used after the last
0. That's possible doable, but definitely much harder to implement.