Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

TakeCommand 31 pipe issue with gvim

Aug
133
4
I use vim and gvim a lot and came across something weird of late. In particular, I can pipe the output of a command into vim easily enough like the following:
dir | vim -
That opens vim with the contents of my current directory loaded into a buffer. I can use the very same command with gvim instead in a Windows CMD shell just fine:
dir | gvim -
That opens gvim with the contents of my current directory loaded into a buffer. But here's the problem: it doesn't work when I use TakeCommand 31 instead. All I ever get is an empty buffer opened in gvim. To be clear, it works fine with vim in TakeCommand 31`, so I assume it's got something to do with the way TakeCommand handles piping to a GUI app rather than a console app. But that's only a guess on my part.,

Any ideas how I might get piping to work into gvim from TakeCommand 31? Thanks!
 
Hello Phileosophos. I'm also a heavy gvim / vim user and I just tried it with gvim without issue.

Code:
TCC  31.01.16 x64   Windows 11 [Version 10.0.22631.2715]

D:\Users\Michael>dir | gvim -

D:\Users\Michael>vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Oct  9 2023 22:07:27)
MS-Windows 64-bit console version
Included patches: 1-2009
Compiled by appveyor@APPVEYOR-VM

Screenshot 2023-11-28 073459.jpg


So that's good news. It does work. The bad news is that I don't really have no idea how to troubleshoot that.

Michael
 
I can't reproduce this either. You might try typing the complete path to gvim.exe, just to make sure you aren't tripping over a forgotten alias or batch file or whatever.
 
Oh wow, I learned something today but still don't understand why it works differently with TakeCommand. I installed vim 9.x using chocolatey, which apparently includes gvim by default. Only it also creates a gvim.bat file in the Windows folder of all things, which looks as follows:
@echo off
rem -- Run Vim --
rem # uninstall key: vim90 #

setlocal
set VIM_EXE_DIR=C:\tools\vim\vim90
if exist "%VIM%\vim90\gvim.exe" set VIM_EXE_DIR=%VIM%\vim90
if exist "%VIMRUNTIME%\gvim.exe" set VIM_EXE_DIR=%VIMRUNTIME%

if not exist "%VIM_EXE_DIR%\gvim.exe" (
echo "%VIM_EXE_DIR%\gvim.exe" not found
goto :eof
)

rem check --nofork argument
set VIMNOFORK=
:loopstart
if .%1==. goto loopend
if .%1==.--nofork (
set VIMNOFORK=1
) else if .%1==.-f (
set VIMNOFORK=1
)
shift
goto loopstart
:loopend

if .%VIMNOFORK%==.1 (
start "dummy" /b /wait "%VIM_EXE_DIR%\gvim.exe" %*
) else (
start "dummy" /b "%VIM_EXE_DIR%\gvim.exe" %*
)
I don't know why any of that might be necessary or why it puts it in the Windows folder for crying out loud, but as soon as I invoke the gvim.exe manually it works properly. Don't ask me why the gvim.bat file works fine with CMD or PowerShell but not TakeCommand, but I have a solution. Thanks!
 
I don't know why any of that might be necessary or why it puts it in the Windows folder for crying out loud, but as soon as I invoke the gvim.exe manually it works properly. Don't ask me why the gvim.bat file works fine with CMD or PowerShell but not TakeCommand, but I have a solution. Thanks!

Maybe just delete the batch file? Create an AppPath entry for gvim.exe instead?
 
The installer specifically asks if you want to "create batch files". It's easy to miss if you're in a hurry or not reading carefully, but it does ask.

And if you haven't checked lately, they have now released Vim/Gvim version 9.1. No big changes, at least nothing I've noticed.
 
The installer specifically asks if you want to "create batch files". It's easy to miss if you're in a hurry or not reading carefully, but it does ask.

And if you haven't checked lately, they have now released Vim/Gvim version 9.1. No big changes, at least nothing I've noticed.
If you refer to the Vim installer, I installed it using Chocolatey, which is a Windows quasi-package-management system that automates installation and doesn't prompt you at all about creating batch files. But that's good to know, should I ever go back to installing things the usually-more-painful way.
 
One reason that I don't use chocolatey, or other similar tools. Although they can be handy. I somehow got crossways with VSCode yesterday. It was installed from the Microsoft Store, which (supposedly) provides automated updates. Only the update was failing, throwing up error popups. And there seemed to be nothing that I could do about that, working from within the Store. Eventually, I deleted the entire directory tree where it was installed, The Store still insisted that it was installed, and wouldn't do anything with it. Winget to the rescue.

If that happens again, I will just move over to the standard installer for VSCode. Pretty much the only things I have installed from the Store are Microsoft tools, VSCode, Sysinternals, and a few others.
 

Similar threads

Back
Top