vim - how to stop this bug: insert single char func - put vs p

I wanted to be able to easily insert a single char from normal mode, and clean up some of the mappings that were being added for that purpose while I was at it. I have this in my vimrc now:

 "insert single char from normal mode
function! InsertSingleChar()
    "jump into insert mode and place character after the cursor
   let l:char = getchar()
   if l:char != 0 
     silent! exec "normal a" . nr2char(l:char)

But the only way to input a p is to wait for it to time out then type it in, or it puts instead.

I call this using the following map:

nnoremap <leader>j :call InsertSingleChar()<cr>

How can I fix it? Appreciated.

I had a mapping and forgot about it, when I searched to be sure I mistyped and missed it. Sorry everyone! Thanks for the help


If I understand you right, you only have a problem with the insertion of p; other letters work fine.

This sounds like you have a jp mapping that is preferred by Vim, so you have to type j (timeout) p to apply your mapping with a value of p, and not trigger the jp mapping instead.

You can check via

:verbose nmap jp

and then probably would have to remap that one to use a second non-printable character, e.g. j<C-P> instead.

Need Your Help

UIScrollView in iOS doesn't response scroll to top

iphone objective-c ios ipad uiscrollview

I have two UIScrollViews, one is horizental, the other is like page on the horizontal view. I want to click the status bar and have the vertical scrollView scroll to the top, but it doesn't work.

Is Webhooks a style/pattern or a specification?

http callback web-applications webhooks

I've been reading about Webhooks and I'm trying to determine if it's a specification vs a style/pattern.