4

Trying to run a vim script as part of a batch file with

vim -u NONE -S dothis.vim 

but what is puzzling is that the batch file exits after this line instead of continuing with the next statement. This happens if the command is inline or is CALLed as a subroutine. If i create another batch file to CALL this command, my main batch will continue executing but on the screen nothing is displayed anymore except "Please press any key . . . " (actual words might differ slightly, dont have it visible on screen anymore), can't see the execution of the batch file anymore (would be important in this case).

dothis.vim is exited with qa! if this would have something to do with the issue (files have been update'd already); it autoedits a bunch of files in subfolders.

2
  • 1
    Put the output of where vim (or even which vim if your command interpreter has a which command) in your question, and you'll make answerers' lives easier. Commented Jan 10, 2014 at 19:07
  • Thank you for mentioning 'where', didn't even know about it. Commented Jan 21, 2014 at 13:19

1 Answer 1

4

The "vim" which is running is probably a .bat file itself. That's what the default installer creates for you, anyway.

When you directly use one .bat file from another, the first .bat file no longer runs, it transfers control to the second without ever returning.

So this will end your .bat file:

vim -u NONE -S dothis.vim

But this should work:

call vim -u NONE -S dothis.vim

Now, you said "this happens if the command is inline or is CALLed as a subroutine". So, did you try this? Because this .bat file works just fine for me:

@echo off setlocal echo starting Vim call vim -u NONE -S dothis.vim echo Vim done! endlocal echo on 

When I call this .bat file, I see both echo messages as expected.

I looked at C:\Windows\vim.bat and verified that there are no exit statements anywhere, which could cause problems in the first .bat file if done incorrectly. If this approach does not work, try posting a full .bat file that does not work for you. As I said, the above works for me just fine. Omitting call makes only the first echo statement run.

1
  • You're spot on. Replacing "vim" with "absolutepath\gvim.exe" fixes the issue. Had totally forgotten about vim.bat. Thank you! Commented Jan 21, 2014 at 13:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.