Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
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. –  JdeBP Jan 10 at 19:07
    
Thank you for mentioning 'where', didn't even know about it. –  kilves76 Jan 21 at 13:19

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
You're spot on. Replacing "vim" with "absolutepath\gvim.exe" fixes the issue. Had totally forgotten about vim.bat. Thank you! –  kilves76 Jan 21 at 13:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.