Why starting gvim in ConEmu works with a task, but not from command line?

1

1

When i enter this in ConEmu:

gvim --windowid %ConEmuBackHWND% -new_console:sH

I get a blank split that after a while says the following:

GUI application (PID=384) was attached to ConEmu:
\Path\To\gvim.exe

While trying to find out what was going wrong i made a "Gvim" task with the following command contents:

gvim --windowid %ConEmuBackHWND% -new_console:sH

(Same as the command i entered above in the command line)
And when i know start the task from the "Create new console" dialog, everything works fine and i get a gvim child window as my right split!

How are the commands being executed from the "Create new console" dialog, and how can i make the above command to spawn a gvim split directly from the console?

Fr0stBit

Posted 2015-09-12T00:40:23.997

Reputation: 113

Answers

1

ProcessExplorer is very helpful tool to detect problems with environment variables and things... I think you have problem because of variable expansion. Try following

gvim --windowid !ConEmuBackHWND! -new_console:sH

When you run the command with percent signs, the CLI replace variables before ConEmu get the command. So, you were trying to run gvim in new split, but telling it HWND from old split.

When you use exclamation signs, variables are not expanded, ConEmu gets the command untouched, and the !ConEmuBackHWND! is expanding by ConEmu itself in proper moment, after split is created and new variables initialized.

Maximus

Posted 2015-09-12T00:40:23.997

Reputation: 19 395

That worked! I didn't know that EnableDelayedExpansion was enabled by default. Would you mind explaining why you believe that the problem happened? – Fr0stBit – 2015-09-12T01:15:00.960

Answer updates, exclamation signs are expanded by ConEmu itself. – Maximus – 2015-09-12T11:53:52.547

Fantastic! Thank you for the explanation. I am still wondering though why the normal environment variable expansion worked with the Task execution. I suppose that it is the same logic as above, the child window is being created with some WinAPI functions and then the command is being expanded in the new window directly, am i right? – Fr0stBit – 2015-09-12T11:59:38.640