I'm trying to call Vim using subprocess, and pass it an argument. For example:
subprocess.call(['gvim.exe', ''' "+map <F5> :echo 'Hello!'<cr>" '''])
This command works on the command line:
> gvim.exe "+map <F5> :echo 'Hello!'<cr>"
And then I hit F5 and it tells me hello.
The subprocess call doesn't work. When I look at the process in task manager, I see that my string is now:
"\" +map <F5> :echo 'Hello!'<cr>\""
Not at all what I expected, and I don't think it's what Vim expects, either. It looks like subprocess is somehow escaping my quotes, but I don't know why.
Is there any way I can get this to work like I expect?
The quotes aren't necessary since
subprocess.call passes the arguments directly to the process without using the shell (unless you set
subprocess.call(['gvim.exe', "+map <F5> :echo 'Hello!'<cr>"]) will suffice.