I want to use CMDR as VS Code default integrated terminal. I have added the following options in my settings.json
"terminal.integrated.shell.windows": "C:\\Windows\\system32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k %CMDER_ROOT%\\vendor\\init.bat"
],
and it was working but with this new VS Code update Version: 1.60.0 it stopped working.
any suggestions? how to fix this?
Also had this problem today and managed to fix it by updating settings.json as follows:
"terminal.integrated.profiles.windows": {
"Cmder": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": ["/K", "C:\\Program Files\\cmder\\vendor\\init.bat"]
}
},
"terminal.integrated.defaultProfile.windows": "Cmder"
Make sure to update the path to cmder to match the install location on your system
These old legacy settings can then be removed:
terminal.integrated.shell.windows
terminal.integrated.shell.windowsExec
terminal.integrated.shellArgs.windows
Related
The '+' button to open terminal in my visual studio code does not work.
Also, the default profile selection button does not work.
The only thing I changed was from "launch.json" to "externalConsole: false->true".
Even if I try to restore it to its original state, it remains the same. I tried reinstalling the VSCode, deleted the "setting.json" file, and recreated it. But... :(
Originally, I was using git bash as a standard, but you can see it. There is only "JavaScript Debug Terminal" left.
Please help me, friends.
My "launch.json" file
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 활성 파일 빌드 및 디버그",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:/MinGW/bin",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "gdb에 자동 서식 지정 사용",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 활성 파일 빌드"
}
]
I am on macOS with an issue like this as well. My terminal instantly closes when I try to open it and I have not found a good solution. The best I can do it just reinstall VScode.
I use Windows, hence commands are for Windows, but you can definitely find the alternative commands for your OS in case you happen to use an OS other than Windows.
Open your settings.json file(File -> preferences -> Settings or Ctrl+,) and look for the configuration terminal.integrated.profiles.windows (newer recommended setting). If you seeterminal.integrated.shell.windows then it is the older deprecated setting.
If you are on linux or Mac, then look for the terminal.integrated.profiles.linux or terminal.integrated.profiles.osx. If you don't find these, then perhaps you don't have any terminal profiles setup and you need to set it up.
Setting up a terminal profile is quite easy.
In your settings.json file you need to create a new setting with key terminal.integrated.profiles.windows (or terminal.integrated.profiles.linux or terminal.integrated.profiles.osx based on your system). Start typing the above key and once VSCode shows the suggestion hit Enter(Return). If you don't see any suggestion for auto-complete try hitting Ctrl+Space. Your settings will auto-populate against the above key and will look something like following:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
}
In addition to above you can also setup a default terminal profile. Include the below setting(here Git Bash has been configured as the default terminal profile) :
"terminal.integrated.defaultProfile.windows": "Git Bash"
You can always use the Ctrl+Space to force VScode to provide you with the possible values.
Few handy links :
To create a new profile.
To go to the command pallette(Ctrl+Shift+P on windows)
When i run echo %Path% in vscode's terminal, the result is:
C:\Users\user\.platformio\penv\Scripts;C:\Users\user\.platformio\penv;C:\Users\user\.platformio\python3;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\NAT Service;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files....
But when I run it in the command line(cmd.exe) the result is:
C:\Program Files\AdoptOpenJDK\jdk-8.0.292.10-hotspot\bin;C:\Program Files\AdoptOpenJDK\jdk-16.0.1.9-hotspot\bin;C:\Program Files (x86)\NAT Service;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerSh...
which is different from the one i got in vscode.
i tried switching inherit env on and off, restarting vscode, and restarting my computer but nothing changes.
How can i make the %Path% in vscode the same as the one in cmd.exe?
my current vscode settings are:
{
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe",
"window.zoomLevel": 0,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.configuration.checkProjectSettingsExclusions": false,
"java.errors.incompleteClasspath.severity": "ignore",
"java.project.importOnFirstTimeStartup": "automatic",
"terminal.integrated.tabs.enabled": true,
"files.autoSave": "afterDelay",
"workbench.colorTheme": "Default Dark+",
"java.configuration.runtimes": [
{
"name": "JavaSE-16",
"path": "C:\\Program Files\\AdoptOpenJDK\\jdk-16.0.1.9-hotspot",
"default": true
},
{
"name": "JavaSE-1.8",
"path": "C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.292.10-hotspot"
},
],
"java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-16.0.1.9-hotspot",
}
for user settings and
"settings": {
"java.configuration.updateBuildConfiguration": "automatic",
}
for workspace settings
If anyone else in the future ends up scratching their heads over this particular problem, I’ve found a culprit:
Terminal>Integrated>Env: Enable Persistent Sessions
I suspect what happens is that after you update system paths, VScode caches the old path in the terminal and persists it. This is also true even if you restart the browser.
Toggling this option off and restarting VSCode clears that cache, and works perfectly for me. You can toggle it back on after you’re done.
I reinstalled the PlatformIO extension and this fixed it.
Something must have gone wrong with the custom path variable option that comes with PlatformIO
close last terminal in vs code by trash icon and open new terminal from Terminal>New Terminal menu in vs code
in new terminal you can see change's
When attempting to setup SDL2 with VS Code in Ubuntu 20.01 LTM I get the following VS Code error:
cannot open source file "begin_code.h" (dependency of "SDL2/SDL.h")
Any tips?
Just add "/usr/include/SDL2/" to your c_cpp_properties.json like so:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/SDL2/"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu18",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
in case you don't have the "c_cpp_properties.json" file in your
folder.
Different answer than above, but I believe might be a better approach.
to create the c_cpp_properties.json on your workspace
do the following:
ctrl + shift + p (opens the command palette)
search for "C/C++: Edit Configurations (JSON)" and click on it
"c_cpp_properties.json" file will be created on your workspace
add "/usr/include/SDL2/" to your "c_cpp_properties.json" like
https://stackoverflow.com/a/64187964/8540466
reload C/C++ IntelliSense extension.
I'm assuming you already have the extension
"C/C++ IntelliSense, debugging, and code browsing"
installed on your vscode.
After these steps this problem was fixed for me.
If you, like me, don't have the c_cpp_properties.json file in your project, you can solve it by adding the following line to your settings.json (in VSCode, hit Ctrl+Shift+P and search for Open settings (JSON)):
{
// ...
"C_Cpp.default.includePath": ["/usr/include/SDL2", "${default}"],
//...
}
I have an existing C++ project that I've configured and built in Visual Studio. This project's only target is Windows, no other platforms. I'm using Bash in WSL to launch the executable.
I prefer to develop in Visual Code (not Visual Studio). I prefer to build and launch applications through Bash (strong Linux background).
Right now, my development workflow is:
Edit code in VS Code
Switch to Visual studio and click the build button
Switch to Bash and execute the built program
Since I only keep Visual Studio open for building, I would much prefer to build by command line through Bash.
My naive approach was to use an open source tool to convert the Visual Studio project file into a CMake file. Then cmake & make from Bash, but I stopped when I started encountering errors looking for windows.h (maybe I just need to add some windows include paths to my include_path).
I'm not sure what the best way to go about this would be. Any suggestions would be appreciated!
If the project is entirely C++, there should be no reason to leave WSL. Building and launching the application can be easily handled right there!
You can absolutely build by the command line in bash by using
g++ -o <outputfile> <inputfiles>
However, the easiest way to run the program is to create a build configuration in Visual Code. You will need 2 files: launch.json and tasks.json
To create the launch file, hit F1 (or open your command pallet) and select Tasks: Configure Default Build Task. It should look something like this.
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}", //input files
"-o",
"${fileDirname}/a.out" //output file
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
To create launch.json, go to the 'debug' tab and select 'create a launch.json file'. It should look something like this
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/a.out", //output file
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
with both of these files in place, all you have to do is hit the run button like in Visual Studio.
MSBuild.exe is provided with my installation of Microsoft Visual Studio. From within WSL bash, I can invoke MSBuild.exe and give the .sln file of my project as the first and only argument.
The compilation output is written to the terminal.
I have been recently trying to use the MinGW gcc compiler with Code, and am getting some issues with Intellisense(not breaking, but I find it annoying).
I followed the documentation to edit the path for the c_cpp_properties.json file, but the error continues to pop up and I think I have also found contradictory information.
{
"name": "Win32",
"includePath": [
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
I looked on the github repo for the documentation and found someone had committed a change where ${workspaceRoot} was changed to workspaceFolder in the documentation. However, root seems to be the default for VS code, and I only updated to the new orange logo version this morning.
https://github.com/Microsoft/vscode-docs/commit/fa613d436a53bd9c5a21065cf5fa0f1b350d9bc6
So which is the correct way to get Intellisense working, Folder or Root?
Turning #Marks comment into an answer: ${workspaceRoot} is deprecated, ${workspaceFolder} should be used instead: https://code.visualstudio.com/docs/editor/multi-root-workspaces
See also this description of variables: https://code.visualstudio.com/docs/editor/variables-reference
${workspaceFolder} - the path of the folder opened in VS Code