These are my scenarios and expected output
function! s:Foo(text) echoerr "'" . a:text . "'"endfunctioncommand ... FooCommand ... (not sure what to write here)FooCommand text
'text'
FooCommand text asdfsfd
'text asdfsfd'
(it's hard to see in stackoverflow but the next one has trailing whitespace)
FooCommand line with 4 trailing spaces
'line with 4 trailing spaces '
FooCommand line with"quotes" here
'line with"quotes" here'
Nothing that I've tried works. I've tried <f-args>
, <q-args>
, <args>
and I've tried manually adding ""
s around the non q-
versions. They all fail for some reason or another.
Either the function will say it didn't get enough args
, Undefined variable
, or including "
s will cut off text at the first double-quote that's found.
The best combination I got was my first try - Use <q-args>
and then manually escape "
s all the time. But even then, <q-args>
doesn't seem to allow trailing whitespace. So I can't use it for what I'm trying to do.
Is there any way for Vim to just let me pass everything as one big string to a function and it just escape everything properly? Including quotes. Including spaces. I just want Vim to take whatever I write and put it in a string.