I know how to create key mappings in normal mode using nmap and in insert mode using imap. However I do not know how to create mappings in replace mode. I would assume it's either rmap or Rmap, but both of these commands are invalid. Which command can I use to create mappings in replace mode in vim?

  • According to the map section in the Vim Reference Manual, there is not a Replace Mode. What are you trying to replace in Normal Mode? – ThatsWhatSheCoded May 22 at 1:40
  • Not sure how much it would help but this question was asked previously: here – ThatsWhatSheCoded May 22 at 1:42
  • By replace mode I am referring to the mode after you type 'R' in normal mode – user29330 May 22 at 2:04

There has no rmap, replace mode map is created in imap with a mode test:

inoremap <expr> <a-k> mode() ==# 'R' ? 'replace' : 'insert'

:h mode() is transient, you must test it in :h map-expr.

Note it won't work for r.

| improve this answer | |
  • What is this command supposed to do? Sorry I do not know very much vimscript. – user29330 May 22 at 1:58
  • @coder54321 It output replace or insert based on your current mode. The :h ... is valid ex command, you can execute it in vim to get help. – dedowsdi May 22 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy