How to reproduce this mapping:
nnoremap <Leader>a :DoSomething <C-r>=do_something_arguments()<CR>
..in a function?
The desired effect is to open command-line mode with some text filled in, and leave it at that.
:normal
only works on "complete commands", same seems to be also true for :exec
.
Reasoning behind this is to define an operator (using vim-operator-user) that would prepopulate a command:
call operator#user#define('conf-entry', 'Op_command_conf_entry')
function! Op_command_conf_entry(motion_wiseness)
normal! `[yv`]
let l:conf_path = '~/.vim/conf/_' . @" . '/'
exec ':EditCreating ' . l:conf_path
endfunction
nmap _c <Plug>(operator-conf-entry)
Here, the exec
line executes immediately, which is the behavior I want to change.
What I'm probably looking for is the command-line-mode equivalent to :startinsert
, something like :startcommand
.
The alternative solution is to use input()
which can offer both prepopulating as well as enabling completion. However this is not exactly command-line-mode.