Skip to content

Instantly share code, notes, and snippets.

@idbrii
Created February 28, 2020 01:09
Show Gist options
  • Save idbrii/d4cd7056c4d626b6b2f940f87a4e0b14 to your computer and use it in GitHub Desktop.
Save idbrii/d4cd7056c4d626b6b2f940f87a4e0b14 to your computer and use it in GitHub Desktop.
Example gvim.bat generated by vim's install.exe
@echo off
rem Created by idbrii based on script from vim 8.2.314
rem See also https://github.com/vim/vim/blob/1fa8d2c33d7290eda7dc2a94d4ec6a599a2d61dd/src/dosinst.c#L842-L950
rem -- Run Vim --
rem # uninstall key: vim82 #
setlocal
set VIM_EXE_DIR=C:\Users\idbrii\scoop\apps\vim-nightly\current
if exist "%VIM%\vim82\gvim.exe" set VIM_EXE_DIR=%VIM%\vim82
if exist "%VIMRUNTIME%\gvim.exe" set VIM_EXE_DIR=%VIMRUNTIME%
if exist "%VIM_EXE_DIR%\gvim.exe" goto havevim
echo "%VIM_EXE_DIR%\gvim.exe" not found
goto eof
:havevim
rem collect the arguments in VIMARGS for Win95
set VIMARGS=
set VIMNOFORK=
:loopstart
if .%1==. goto loopend
if NOT .%1==.--nofork goto noforklongarg
set VIMNOFORK=1
:noforklongarg
if NOT .%1==.-f goto noforkarg
set VIMNOFORK=1
:noforkarg
set VIMARGS=%VIMARGS% %1
shift
goto loopstart
:loopend
if .%OS%==.Windows_NT goto ntaction
if .%VIMNOFORK%==.1 goto nofork
start "%VIM_EXE_DIR%\gvim.exe" %VIMARGS%
goto eof
:nofork
start /w "%VIM_EXE_DIR%\gvim.exe" %VIMARGS%
goto eof
:ntaction
rem for WinNT we can use %*
if .%VIMNOFORK%==.1 goto noforknt
start "dummy" /b "%VIM_EXE_DIR%\gvim.exe" %*
goto eof
:noforknt
start "dummy" /b /wait "%VIM_EXE_DIR%\gvim.exe" %*
:eof
set VIMARGS=
set VIMNOFORK=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment