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

EF Object entity State moves to Unchanged when attached to new Context

linq entity-framework save

I have go the oddest problem, I get an object from EF and pass it back to the Business Logic for manipulation, when finished i'm trying to save the object back to the DB, when the object is passed ...

Bash Pipe Handling

linux bash pipe device

Does anyone know how bash handles sending data through pipes?