I'm trying to create a dynamic line to execute, currently I have
execute a:modes[i] .'noremap <silent> <buffer> '. l:key .' <Esc>:call HardModeEcho(g:HardMode_hardmodeMsg)<CR>'
I'd like that to be something like
execute sprintf(
"%snoremap <silent> <buffer> %s <ESC>:call HardModeEcho(g:HardMode_hardmodeMsg)<CR>",
a:modes[i],
l:key
)
Actually it needs to get even more complex. But, I'd like to start with that. Is there any such functionality in vimscript?
:help sprintf, and I looked for it on Google. Didn't know aboutfunction-list– Evan Carroll May 02 '17 at 17:28printffunction to print, you would have to use:call printf(..), which is exactly the same length as:echo printf(..). Not really much value in having such a function, so might as well return a string. Arguably,sprintf()would have made been a better name, but OTOHprintf()saves us one character of typing ;-) – Martin Tournoij May 02 '17 at 17:36:callon a string in void-context is echo. Perhaps that makes some degree of sense, but you don't see that kind of stuff in other languages. Forgive the simple question. I'm just trying to write a quick patch for hardmode. – Evan Carroll May 02 '17 at 17:42