The following should solve your issue:
nnoremap <expr> : ShowLastCmd()
function! ShowLastCmd()
echohl ModeMsg
echo ':' . getreg(':')
echohl None
while 1
try
let char = getchar()
if char == '^\d\+$' || type(char) == 0
let char = nr2char(char)
endif
catch /^Vim:Interrupt$/
return ''
endtry
if char == "\<cursorhold>"
continue
elseif char == "\<cr>"
executereturn ':' . getreg(':')
. "\<cr>"
return ''else
endif
return ':' . char
endif
endwhile
endfunction
The while
loops is there to catch the <cursorhold>
key event.