Tuesday, March 10, 2020

Windows vimtutor problems

This is a copy of my issue submitted on GitHub. Maybe the mailing list is still the preferred place for discussions?


The current vimtutor.bat has several problems. It basically does not work on modern Windows with the default installation path.

When launching the vim tutor from the start menu, one can see that the tutor appears. The problem is that it is not the copy as intended, but just the tutor file under "C:\Program Files (x86)\Vim\vim82\tutor". After digging around a bit, I have found:

Problem 1: vimtutor.bat cannot really determine whether a directory is writable or not.

FOR %%d in (. "%TMP%" "%TEMP%") DO IF EXIST %%d\nul SET TUTORCOPY=%%d\$tutor$

This line does not work. I am not sure whether it used to work or not, but it does not now. "C:\Program Files (x86)\Vim\vim82" is not writable in modern Windows, but the script cannot detect the case.

After struggling with the batch file for a while (oh, bash looks such a beauty, when compared with the quirkiness of Windows batch), I changed that line to the following:

FOR %%d in (. %TMP% %TEMP%) DO (  call :test_dir %0 %%d  IF NOT ERRORLEVEL 1 GOTO dir_ok  )    echo No working directory is found  GOTO end    :test_dir  SET TUTORCOPY=%2\$tutor$  COPY %1 %TUTORCOPY% >nul 2>nul  goto end    :dir_ok

At this step, vimtutor.bat can run successfully from "C:\Program Files (x86)\Vim\vim82", i.e. the shortcut. However, I still cannot run the vimtutor.bat script at the command prompt in my home directory, because:

Problem 2: vimtutor.bat does not encode the path of gvim, and the wait behaviour of gvim.bat is different than gvim.exe.

This can be changed by changing gvim to "%~dp0gvim.exe".

:ntaction  start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim"  IF ERRORLEVEL 1 GOTO use_vim    :: Start gvim without any .vimrc, set 'nocompatible'  start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "set nocp" %TUTORCOPY%

BTW, the -console path requires vim.bat and running from a path other than "C:\Program Files (x86)\Vim\vim82" (if run without the ".bat" suffix). This should not be a problem in daily usage (the quirky behaviour of batch makes solving the problem harder than I expected).

I believe this basically solves the problem, although maybe breaking compatibility with pre-NT Windows. Since the Vim executables already requires Windows 5.1, we can probably eliminate the non-NT paths in the batch file.

Thoughts? If it is OK, I can provide a patch/PR.


--
Yongwei Wu
URL: http://wyw.dcweb.cn/

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CADs46ifTZ0pmsbkZTHaE3JdDPA2mzyB39gqWA1v0-nBZhkOwDw%40mail.gmail.com.

No comments:

Post a Comment