1

I have some inoremap's in my vimrc, such as

inoremap \c <c-v>u2705

which enters a ✅ emoji for when I am writing checklists.

However, I noticed that while I am able to use it when in insert mode and in Replace mode (triggered using R), I am not able to call the mapping when calling r (when trying to replace a single character). It just ends up replacing with \ and then triggering c.

Is there a reason why r doesn't actually switch the mode to insert/replace? Is it tied to its own special mode?

And is there a workaround to enable me to replace a single character using r with my inoremap?

4
  • Why not using an abbreviation instead (:ab \c ✅)? Incidentally, it also works in Replace mode.
    – r_31415
    Commented Jun 30, 2022 at 6:03
  • @RobertSmith "it works in Replace mode" means it works when using R, not r, which is the crux of the question.
    – D. Ben Knoble
    Commented Jun 30, 2022 at 18:26
  • The only solution I can think of using r is r<C-v>u2705, which defeats the purpose.
    – D. Ben Knoble
    Commented Jun 30, 2022 at 18:27
  • @D.BenKnoble You're right. I think if OP needs more than 1 character to trigger the mapping, then switching to Replace mode becomes a requirement.
    – r_31415
    Commented Jun 30, 2022 at 22:48

1 Answer 1

1

Even though r supports lmaps and digraphs, it does not switch the Insert mode, unlike, say, R. And so your mapping won't be applied.

You need to get used to typing something different, for example, s\c<esc>.

Is it tied to its own special mode?

The docs do not call it "a mode" specifically. This is rather "get and use a char" thing. Kind of what does f, t and such.

2
  • Is there a way to map r to do that?
    – WalksB
    Commented Jun 30, 2022 at 16:09
  • @ZaidGharaybeh I don't think it's worth an effort.
    – Matt
    Commented Jun 30, 2022 at 17:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.