How to use quotes in Visual Studio Code settings values? - visual-studio-code

I'm trying to add this as my default terminal: C:\Windows\System32\cmd.exe /k "C:\Program Files\nodejs\nodevars.bat" but how do I set the "/k "C:\Program Files\nodejs\nodevars.bat" part in terminal.integrated.shellArgs.windows settings. It doesn't allow for nested quotation marks. I tried escaping the quotation marks, double quotes etc. Each option the command prompt states the path set is invalid.

go to File menu > Preferences > workspace settings. On right hand side, you will see settings.json. In this file add below line-
"terminal.integrated.shell.windows": "C:\\Windows\\system32\\cmd.exe /k \"C:\\Program Files\\nodejs\\nodevars.bat\""
thats it. now you can run npm install and npm start commands to run your angular2 application.
see if this helps.

I think \" does not work for cmd shell args but this works for me:
"terminal.integrated.shell.windows": "C:\\Windows\\system32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat",
"&&start-ssh-agent"
],

Related

How to integrate Developer Command Prompt for VS 2022 as Terminal in VS Code

I would like to have the Microsoft VS C++ compiler cl available in VisualStudio Code.
I have Visual Studio Build Tools installed and can call cl from the Developer Command prompt.
The default way recommended by Microsoft to get VS Code to use the cl compiler is to call VS Code from the Developer Command prompt.
I would like to do it differently, with a terminal that I can call from VS Code and make it the default terminal if needed.
In Windows Terminal, I get the automatically generated Developer Command prompt entry with the command line:
cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=x64 -host_arch=x64`
or
powershell.exe -NoExit -Command "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell 0d0637f3 -SkipAutomaticLocation -DevCmdArguments """-arch=x64 -host_arch=x64"""}"
If I paste this line into an existing vscode terminal, it works and I can use the cl compiler. But I can't manage to get it into an integrated terminal in settings.json.
This is what I tried in the settings.json:
"Developer Command Prompt for VS 2022": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe /k \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\" -arch=x64 -host_arch=x64",
"${env:windir}\\System32\\cmd.exe /k \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\" -arch=x64 -host_arch=x64"
],
"overrideName": true,
"args": [],
"icon": "terminal-cmd"
},
Since VScode is pretty smart, it recognizes that this won't work and doesn't even list it as an entry within the available terminals.
Furthermore, i have absolutely no idea what to do with the commandline given for PowerShell, notably the three doublequotes after Import-Module and how to handle them.
Try the following to load VsDevCmd.bat in cmd.exe from the VSCode integrated terminal.
For running it through PowerShell, you should be able to just replace the path with PowerShell, and alter the arguments to match accordingly (/k would become -NoExit, etc).
"VsDevCmd (2022)": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [
"/k",
// Path below assumes a VS2022 Community install;
// update as appropriate if your IDE installation path
// is different, or if using the standalone build tools
"C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/VsDevCmd.bat",
"-arch=x64",
"-host_arch=x64"
],
"overrideName": true,
"icon": "terminal-cmd"
},

Visual Studio Code terminal error: The filename, directory name, or volume label syntax is incorrect

I have this issue in microsoft visual studio code, whenever I open the terminal the first message I get is The filename, directory name, or volume label syntax is incorrect. The terminal works fine.. just it bugs me to see see this error message whenever I open the terminal.. how do I fix it?
I Installed Cmder as my default visual studio code terminal, maybe there is something related to this error?
thanks in advance
I am not sure how you have installed cmder as the integrated terminal in vscode but in settings.json you could try pointing the terminal.integrated.shell.windows to cmd.exe and the terminal.integrated.shellArgs.windows to what makes cmd.exe be (act like) cmder which is cmder's init.bat file. So in your vscode settings.json add or modify the below lines to point to your cmd.exe and cmder init.bat respectivley.
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [ "/k", "C:\\cmder\\vendor\\init.bat"],
I got the same problum but it got fixed by following this steps
go to setting and search json
click on launch -(Edit in setting.json)
now replace the line "terminal.integrated.shell.windows":(path as showing) line to
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
"terminal.integrated.shellArgs.windows": [ "/k", "C:\cmder\vendor\init.bat"],
save the program. Done!

Cmder with PowerShell in VSCode not registering keyboard shortcut

I was able to setup VSCode so that I use Cmder on top of powershell.exe.
I was hoping that this would allow me to use common keyboard shortcuts such as Ctrl+Backspace to remove words faster. Unfortunately, it only outputs '^W' each time I hit that shortcut. In the standard cmd.exe or Cmder outside of VSCode this shortcut works.
Any idea why that is? I was thinking that that I'm expecting form this might not even be something that's supposed to work.
Thanks!
Here're my settings for reference:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows": [
"-ExecutionPolicy",
"Bypass",
"-NoLogo",
"-NoProfile",
"-NoExit",
"-Command",
". 'C:\\Users\\..\\..\\Apps\\cmder_mini\\vendor\\profile.ps1'"
],

VSCode + Cmder integration - strange issue

could you tell me why while I integrate the vscode and cmder, like that:
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": ["/k", "%CMDER_ROOT%\\vendor\\init.bat"]
and use mini_cmder version, everything is working fine. But if I do it the same with full version of cmder, the "Open in terminal" option from contextual menu doesen't work. Anybody know how to resolve that?
Best Regards,
crova
Yes, to use the Cmder shell in VS Code, you need to create a vscode.bat file in your cmder path with the following contents:
#echo off
SET CurrentWorkingDirectory=%CD%
SET CMDER_ROOT=C:\cmder (your path to cmder)
CALL "%CMDER_ROOT%\vendor\init.bat"
CD /D %CurrentWorkingDirectory%
then in your VS Code user settings, add the following to your settings.json file:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "C:\\cmder\\vscode.bat"]

In Visual Studio Code, how do you inject clink into the integrated terminal?

I was using clink with ConEmu for various node related tasks on windows, but now I'm trying Visual Studio code.
How do I inject clink into Visual Studio Code's integrated terminal, so that I can get real command history persistence between sessions, incremental history search, etc.?
With ConEmu I could inject clink by dropping the clink folder into a specified pickup directory.
I've tried using the path to the included clink bat file, and the clink exe in the VS Code setting terminal.integrated.shell.windows but these spawn and then close the command shell immediately.
Thanks!
I discovered that you can pass arguments to the integrated shell in Visual Studio Code. Combined with the cmd.exe /K option which Carries out the command specified by string but remains, clink can be injected.
In VS Code, go to File > Preferences > Settings or use Ctrl , and add the settings:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "C:\\path\\to\\clink\\clink_x64.exe inject"]
This is the equivalent of opening a command prompt in Windows, and running clink_x64 inject.
It is not answer for your question, but there is another trick to see cmder and text editor in one window. You can open your text editor as another tab in cmder, which I described here:
https://medium.com/#WMorkowski/protip-integrating-cmder-with-text-editor-7f08a6e76de7
from article:
Run your cmder.
Go to ‘Settings -> Startup -> Environment’
Type: set EDITOR_PATH=C:\Program Files (x86)\Microsoft VS Code\Code.exe alias editor="%EDITOR_PATH%" $1 -new_console:s50V Where
in the first line you should type path to your text editor (I was
testing it on Visual Studio Code and Sublime, but it should work with
other editors).
Save your settings
Type ‘editor’ command in command line.
Whoa! We almost finished. But in most cases you don’t want console tab
to be attached to the top of the window. You should close console tab,
and open it again, paying attention to check “New console split to
bottom” checkbox and choose the right console type. Now when you
finally set everything up, you should go to ‘Settings -> Startup’, and
check “Auto save/restore opened tabs” checkbox to save our new
workflow. Now every time you run cmder, your tabs setup will be
restored.
Expanding on my comment:
Open settings.json with:
File > Open > %APPDATA%\Code\User\settings.json
And assuming you installed clink with the magic of chocolatey:
choco install clink-maintained
Then your clink_x64.exe lives here:
C:\Program Files (x86)\clink\clink_x64.exe
And the lines you add to settings.json look like:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/K",
"C:\\Program Files (x86)\\clink\\clink_x64.exe",
"inject",
"--profile",
"~\\clink"
],
Note the addition of --profile ... this allows the history to be persistent between vscode sessions.