1

I'm doing a plugin which modify how shift works and remap <C-d> in insert mode. Every thing works well but I have a problem with 0<C-d>. It is a built-in mapping which reset the indentation to 0. Because I've mapped <C-d>, when I type 0<C-d> I get the behavior of typing 0 followed by <c-d> ie the behavior of my plugin, so I end up with a 0 inserting in the text. Is there a way to "detect" that a 0 has been typed just before ?

Of course I could just inoremap 0<C-d> to 0<C-d> (which is the behavior which I want) but it then means that each time I am typing 0, vi enter in mapping mode, which is annoying.

5
  • To add a count to your mapping you probably want to check this answer, the answers to this question or simply :h v:count
    – statox
    Nov 23, 2022 at 13:39
  • Alas, v:count is set to 0 where 0 has been pressed or not, so can't be used to differentiate a normala C-D to 0<C-D>
    – mb14
    Nov 23, 2022 at 13:44
  • v:count1 then?
    – statox
    Nov 23, 2022 at 13:46
  • Same thing, but returns 1 whatever instead of 0.
    – mb14
    Nov 23, 2022 at 13:47
  • Ah yes I get it now. Indeed I don't know if there's a better option than mapping 0<c-d>
    – statox
    Nov 23, 2022 at 13:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.