1

I have a Windows batch file that I use to edit files using Notepad++

@echo off

if [%1] == [] (

    C:\PROG\Notepad++Portable\Notepad++Portable.exe

) else (

    C:\PROG\Notepad++Portable\Notepad++Portable.exe %CD%\%1

)

Which works fine and I am trying to do the same for gVim (the Windows version of Linux's Vim).

@echo off

if [%1] == [] (

    C:\"Program Files (x86)"\Vim\vim74\gvim.exe

) else (

    C:\"Program Files (x86)"\Vim\vim74\gvim.exe %CD%\%1

)

But the part where I need it to edit/create a document as an argument doesn't seem to work for gVim.

It works fine for Notepad++

C:\PROG\Notepad++Portable\Notepad++Portable.exe \directory\name\editFile.txt

Then when I try in gVim

C:\"Program Files (x86)"\Vim\vim74\gvim.exe \directory\name\editFile.txt

It opens up without acknowledging the argument.

2 Answers 2

1

I’m not very familiar with batch file scripting and how the Windows command interpreter processes white space but I found that enclosing the entire path of the command in double quotes worked for me when I was creating a batch file for the ItsAllText extension for Firefox:

"C:\Program Files (x86)\Vim\vim74\gvim.exe" "%1"
1
  • This is quite interesting I will give it a try Mar 23, 2016 at 14:09
0

Something I just realised is it is only the Graphical Vim that isn't allowing me to edit files via the command line (gvim.exe)

However the Standard Vim seems to work perfectly (vim.exe). I have updated my Windows Batch Script to use this instead and it is working fine

@echo off

if [%1] == [] (

    C:\"Program Files (x86)"\Vim\vim74\vim.exe

) else (

    C:\"Program Files (x86)"\Vim\vim74\vim.exe %CD%\%1

)
1
  • vim -g file - -g Run using GUI (like "gvim")
    – DavidPostill
    Mar 23, 2016 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .