Using file paths with spaces in gVim and Windows 7

This is my path copied from the context menu of Windows Explorer: "C:\Vim Python\getTime.py" , and I'm trying to use the case-sensitive Vim expression, as shown in the Derek Wyatt blog, to paste the output from the given Python script into the buffer.

I tried all the combinations that I can think of with a slash and quotation marks to get the following command to bind <cj>d to insert the script output as follows:

imap <cj>d <cr>=system("C:\Vim Python\getTime.py")<cr>

but I cannot get it to work without inserting the following error:

'C:\Vim' is not recognized as an internal or external command, operable program or batch file.

What do I need to change to use the file path with spaces in it?

If you want to see what I tried, look at pastebin for a good laugh. The searches that I performed lead me to somewhat different places , but none of them solved my problem, or at least I did not read them correctly.


The correct solution for me was:

 imap <cj>d <cr>=system(shellescape('C:\Vim Python\getTime.py'))<cr> 

Thanks Chiel here

+4
source share
1 answer

Use the shellescape vim function. Type :help shellescape in vim to get specific information.

Therefore, changing your line to imap <cj>d <cr>=system(shellescape("C:\Vim Python\getTime.py"))<cr> should be done.

+4
source

Source: https://habr.com/ru/post/1437465/


All Articles