A modified version of Romain's gist.
See prior revisions for functionality closer to the original. This is now a simplification that aims only to provide prompts that would typically follow basic commands.
function! ExpandCommand(pattern) abort
let aliases =
\ { 'cn' : 'cnext'
\ , 'cp' : 'cprevious'
\ , 'g' : 'global'
\ , 's' : 'substitute'
\ , 'v' : 'vglobal'
\ }
let completion = getcompletion(a:pattern, 'command')
if &ignorecase
call filter(completion, "v:val !~# a:pattern")
endif
let completion = len(completion) == 1 ? join(completion) : ''
return get(aliases, a:pattern, completion)
endfunction
augroup AutoReply
autocmd!
autocmd CmdlineLeave :
\ execute 'silent doautocmd AutoReply User'
\ ExpandCommand(getcmdline())
autocmd User marks call feedkeys(':normal!`', 'n')
autocmd User oldfiles call feedkeys(':edit#<', 'n')
autocmd User buffers call feedkeys(':buffer' . "\<Space>", 'n')
autocmd User files call feedkeys(':buffer' . "\<Space>", 'n')
autocmd User ls call feedkeys(':buffer' . "\<Space>", 'n')
autocmd User clist call feedkeys(':silent cc' . "\<Space>", 'n')
autocmd User llist call feedkeys(':silent ll' . "\<Space>", 'n')
autocmd User registers call feedkeys(':silent put' . "\<Space>", 'n')
autocmd User tags call feedkeys(':tjump' . "\<Space>", 'n')
autocmd User undolist call feedkeys(':silent undo' . "\<Space>", 'n')
autocmd User changes call feedkeys(':normal! g;' . "\<S-Left>", 'n')
autocmd User jumps call feedkeys(':normal! �' . "\<S-Left>", 'n')
autocmd User chistory
\ if getqflist({'nr' : '$'}).nr > 1
\ | call feedkeys(':silent chistory | copen', 'n')
\ | call feedkeys("\<Home>\<S-Right>\<Right>", 'n')
\ | endif
augroup END
Tried using it as opposite to romain's CCR because it allowed me to
nnoremap ,c :changes<CR>
. Whereas with romain's i didn't know how to do that.However, it collided with other stuff that used CmdLineLeave such as the builtin method motions for python filetypes for instance.
So if in visual mode i try to any method motion [m [M ]m ]M, it will jump to that motion but also it will stop visual selection in its tracks by ':' in command-line-mode.