Reputation: 12016
I have the following:
map <F6> :SCCompile<cr>
map! <F6> <c-r>=SingleCompile#Compile()<cr>
I'd like to use :SCCompile
in the second mapping too, is that possible?
Currently I have another command which I really don't want to wrap in a function call. I use <c-r>=
in insert mode because it doesn't create undo points and it aways works good except for this limitation.
I've tried execute but it's not working.
Upvotes: 0
Views: 299
Reputation: 172768
You can built on my answer from your recent similar question. It's exactly the same issue: Like :call
, a custom Vim command doesn't return anything, but <C-R>
requires an expression that returns something:
function! SingleCompileWrapper()
SCCompile
return ''
endfunction
map! <F6> <C-R>=SingleCompileWrapper()<CR>
Upvotes: 0
Reputation: 5262
You can do something like this:
map <F6> :SCCompile<cr>
map! <F6> <c-r>=feedkeys("<c-o>:SCCompile\<lt>cr>")?'':''<cr>
The command isn't the simplest:
<c-r>=
<lt>
to allow expanding of <cr>
in command-line mode instead of in <c-r>=
?:
operator to ignore value returned by feedkeys()
functionSee :help feedkeys()
.
Upvotes: 1