When I click 'Run code' on the top right corner, or right click then click 'Run code', or use Ctrl+Alt+N, the integrated terminal does not appear and code could not run.
However, I can open the integrated terminal in vscode under View, and able to run code there using commands.
I believe my setting is correct as following. The problem happens suddenly, regardless of language.
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"code-runner.runInTerminal": true,
So How do I solve this to enable running code directly?
I had the same problem, and solved it by adding:
"folders": [
{
"path": "."
},
],
to my code-workspace file
I also had the same problem, look how I had solve this problem with the help of my friends (Dipesh and Vinit).
Steps:
Open VS code
On the left bottom-corner click on Manage and go into the settings.
In the search settings type code runner, scroll-down and put tick-mark in 'Run In Terminal'.
After that check by running your code.
Related
i am a newcomer to this site and i'm not english so excuse me if this post isn't as good as you expected. Let's get to the point: to give you an example of what i mean with "run button", take the python one for example.
Once you install python extension in visual studio code, you can press a button in the right top of the screen, and then vsc automatically executes a command in a shell running python on the active .py file.
Given this example, I'd like to know how to make a button for vsc that automatically creates a new terminal, executes a command which i would insert in the making of the button and nothing else, of course the terminal shall not disappear after giving the desired output.
Just to give you some more info, i'm on ubuntu, if that helps anyhow.
Feel free to tell me whether i should edit this question in anyway.
Install the Task Runner extension. Now, every task you add to tasks.json will be displayed as a button, in the 'Task runner' panel (which is normally on the same tab as the file explorer).
Here's a decent tasks.json template:
{
"version": "2.0.0",
"tasks": [
{
"label": "COMMAND NAME",
"type": "shell",
"command": "YOUR COMMAND HERE",
"presentation": {"echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true},
},
// More tasks here, if you need them.
]
}
Put this file in your project directory, in a directory called .vscode. Open the project directory with "File" -> "Open Folder".
I know you did not ask for debugging, but you can use the debugger launch mechanism on arbitrary programs. You can define launch.json to implement any number of launch configurations. The currently selected configuration will display a button you can click on.
https://code.visualstudio.com/docs/editor/debugging
Install Code Runner extension in VS Code
you can add the Code Runner extension.
This will show a run button on top of the editor panel
Add Code Runner Extension and you will see a RUN BUTTON on the Top Right in VS code. Like this
I just did a fresh install of Windows 10 Pro version 1903 build 18362.116 and Visual Studio Code. Now the integrated terminal only launches externally.
Pressing Ctrl + ~ results in this.
What am I missing? How do I get it to open integrated again?
EDIT
After working with VSCode team it is a verified bug. See the Github issue here. I posted the workaround as an answer here.
OK, worked through this one in VSCode repo issues.
For now, until it's fixed, turn off ConPTY integration in the User Settings.
💥💥💥
The issue now says use legacy console. To change the setting open a cmd prompt. Right click the title to bring up properties.
Then Uncheck 'Use legacy console'
To change the integrated terminal on Windows, you just need to change the terminal.integrated.shell.windows line:
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Check if "terminal.integrated.shell.windows" has value "C:\\Bin\\Cmder\\Cmder.exe" setting to the User Settings document on the right.
Remove this line.
Ctrl + ~ will now open integrated terminal of VSCode.
If the above solution doesn't work then can you try below values and check if it works for you:
// Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// PowerShell
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
From the Command Palette (Ctrl+Shift+P), use the View: Toggle Integrated Terminal command.
Try custom shortcut:
[
{
"key": "ctrl+`",
"command": "workbench.action.terminal.toggleTerminal"
}
]
Had this problem fixed. Found the solution from the VS Code support.
for error:
Terminal exits with code 3221225786 (or similar)#
"This can happen when you have legacy console mode enabled in conhost's properties. To change this, open cmd.exe from the start menu, right-click the title bar, go to Properties and under the Options tab, uncheck Use legacy console."
source: VS Code docs
Using Visual Studio Code v 1.32.3 on Windows 10, when I navigate to Debug > Add Configuration, nothing happens. No errors or other messages, nothing appears to be written to the workspace folder, no errors in Event Viewer, so far just nothing.
I am somewhat new to VSCode so please don't discount that this might be a newbie error. Potentially notable is that the project is a Cordova project, I have created a Workspace (and confirmed that I am using it and not just opening the folder).
What I have checked so far:
Verifying that nothing is actively trying to build or otherwise access that folder. PhoneGap Desktop is stopped and no emulators running.
Restarted PC
Reinstalled the Cordova Tools plugin
Interestingly if I open a new instance of VS Code and before opening any file or folder I go back to Debug > Add Configuration I will get a message "Please first open a folder in order to do advanced debug configura..." So this indicates that there may be a problem with my workspace or directory but I haven't found it yet.
Any ideas greatly appreciated.
Edit 1:
Version of Cordova Tools is 1.8.0.
I've since tried adding my own launch.json to the .vscode directory. Contents:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run android on device|emulator",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "device|emulator",
"sourceMaps": true,
"cwd": "${workspaceFolder}"
},
]
}
Notable is that in the bottom right corner of the window a "Add Configuration" button appears while I am viewing launch.json and it does appear to work correctly, prompting me with snippets to add.
None of these impact my ability to debug unfortunately.
Alright I think I have this working. Steps:
I deleted the launch.json added in my edit. (Effectively now no launch.json file again)
Navigate to Debug > Start Debugging
Ignore the error dialog that appears
VSCode will create a launch.json and display the debug menu
From here it looks like I'm back on track.
Check VS Code OUTPUT window. When VS Code is downloading some launcher packages like .NET Core Launch, Debugging process may be affected.
After downloading packages are completed check it again.
ctrl + shift + P then enter "reload window" works for me
For me when I press Add Configuration from the dropdown on the upper left it does nothing, I keep pressing up and down in and out of places and suddently it works... then it does not again...
However I found a blue button on the lower right of the screen that works more consistently, I'm uncertain if it is the same issue or that button doesn't work for you either but this was my own experience.
Did you install the latest version of VS Code? I had the same problem and I fixed it by updating to the latest version.
One silly mistake that may lead to this problem is and that I did was to debug when in a non executable file, so be sure to be in that file which is executable. In my case it was a .cpp file where I should've been but I was in one of the header file .h that I created while debugging.
You should delete .vscode folder and run again debugger extension.
This will generate a new .vscode folder with a launch.json file in.
Someone know's how to remove this box:
"help" box
It's better showed here
Open the menu, chose the command File > Preferences > Settings to open or create a settings.json file where you can modify the behaviour of Visual Studio Code.
In this file, add the following line at an appropriate place:
"editor.parameterHints": false,
In newer version of Visual Studio Code you have to use this instead:
"editor.parameterHints.enabled": false,
Reference:
Intellisense in Visual Studio Code
Visual Studio Code User and Workspace Settings
I went to File->Preferences->Settings and a tab opened with Commonly Used at the top. Did Ctrl-F to search parameter, then uncheck the box which is saved automatically it will say. Done.
For me it didn't work but someone on github mention that once you start typing, if the parameter hints show up, just press **ctrl + space** and it won't show up again. It was simple and easy!
Can we add multiple different terminals in the VS Code? I am planning to add following three terminal and work with all of those :
Windows Command prompt
PowerShell
Git Bash
I know I need to add the following command in Preferences => Setting
// // 64-bit cmd if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe",
// // 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
// // Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
I want to add all of the above three commands in setting.json
And when I click + different terminal should open and I want to work with those terminals without changing the preferences.
Is it possible in VS Code or not?
There is a way to make this happens with these steps by installing an extension:
Find an extension called Shell launcher and install it or you can find it here. Reload VS Code if you want or after you finished all steps.
Go to Files --> Preferences --> Settings and this will open settings.json file and you then insert this (you can edit this to your heart's content):
Code:
"shellLauncher.shells.windows": [
{
"shell": "C:\\Windows\\<sysnative>\\cmd.exe",
"label": "cmd"
},
{
"shell": "C:\\Windows\\<sysnative>\\WindowsPowerShell\\v1.0\\powershell.exe",
"label": "PowerShell"
},
{
"shell": "C:\\Program Files\\Git\\bin\\bash.exe",
"label": "Git bash"
},
{
"shell": "C:\\Windows\\<sysnative>\\bash.exe",
"label": "WSL Bash"
}
]
PS: You can use shellLauncher.shells.linux for Linux or shellLauncher.shells.osx for macOS.
Go to Files --> Preferences --> Keyboard Shortcuts and then find on {} icon on the top right corner to open keybindings.json file. Insert this:
Code:
[
{ "key": "ctrl+alt+`", "command": "shellLauncher.launch" }
]
Update: Type shelllauncher into the search bar. You can then see Shell Launcher: Launch command. Highlight and use any keybinding you like. For example, I picked Ctrl + Alt + (backtick)` for myself.
You can reload your VS Code and click the key combination you have assigned and that will give you the option to choose which integrated terminal you want to use.
For more details, please check the official site: https://marketplace.visualstudio.com/items?itemName=Tyriar.shell-launcher
Enjoy!
Even the question is asked last year and the answer is accepted but still I feel to answer this question as I didn't found any simple, suitable and complete answer while as a development I need multiple terminal handy in a click like below:-
and I don't bother about their path, add another extension for what the VS Code is already capable of or reload VS Shell etc and go to insert and setup the settings files manually.
I found this question is asked many times and almost all landed up manually setup of write some settings etc. or sometimes only opted to get a single type of terminal. The answer of #Pawan is somewhat near but again that solution finally land up to a single terminal, going to command setup for switch terminal and this one will work for git or any other terminal.
If you have tools installed which worked on command line like power-shell and git along with default cmd prompt in windows then the follow the quick three steps to get all terminals at once and switch to anyone with a click.
Open terminal, it should be visible (use ctrl+` or from menu View-> Integrated Terminal )
Open commands search (use Ctrl+Shift+P or from menu View->Command Palette...)
In command box Type "Terminal: Select Default Shell" to select this option from drop down.
As you select this option, then all the available commands which are in path will be listed below like below
Just click any one which you like to add for quick access from command list.
Finally, in the terminal window, just click on + sign next to terminal list as shown below:-
The terminal selected in step 5 will now added after performing step6 to the list without removal of earlier terminal.
Repeat step 3-6 for adding any other terminal to command list.
To work with particular terminal just select the required one in the terminal list of the terminal window.
press ctrl + shift + ` shortcut, or press a cross sign to run new terminal, then type bash if your default mode is powershell or powershell if your default mode is bash. And here you are, your terminal is switched.
For now VS Code support defining only one of available terminals as default at a time and you can not add multiple shell terminals.
If you don't want to install "Shell Launcher" plugin as suggested by #ian0411 then here is a quick way to change/select default terminal.
Press "Ctrl + Shift + P" to open the Command Palette.
Type "Terminal: Select Default Shell" and hit enter. You will be prompted to select Git Bash, PowerShell or Cmd as shown below:
Note: This will change the default shell terminal but there is no harm changing it whenever you need to use another.
BTW, if you need to switch only between Cmd & Powershell then you can type cmd or powershell (in already opened terminal) to switch to desired terminal. But it would not work for Git Bash.
I don't see this in the above, but read all the answers. I think this is the best approach for what is supported right now. I believe, like myself, the OP simply wants to open VSCode, and down yonder on the terminal window, we just want a list of options to open from.
Yes, you can open the command, "Terminal: Select Default Shell" and loop through that to add various types of terminals...
Followed by:
I don't know when this option was added to the dropdown, but look! No need to start by looking up the command. I think this is a lot smoother than any other answer, but it still results in the annoying overwrite of your default term to whatever your last choice was before leaving session.
Here, we can more easily open the Select Default Shell - it should support "Select New Shell". Simple, you'd think. Hopefully someone adds that soon or I have time to contribute.
I'm fairly certain that these are old-style settings.json and won't work as discussed in VS Code 2021. The new style looks like:
...
"terminal.integrated.profiles.windows":
{ "Bash":
{ "path": ["C:\\Programs\\Git\\bin\\bash.exe"],
"icon": "terminal-bash",
},
"Command Prompt":
{ "path": ["${env:windir}\\System32\\cmd.exe"],
"args": [],
"icon": "terminal-cmd"
},
"PowerShell":
{ "path": ["C:\\Programs\\PowerShell\\pwsh.exe"],
"source": "PowerShell",
"args": [],
"icon": "terminal-powershell"
},
},
"terminal.integrated.defaultProfile.windows": "Bash"
...
That will get you access to Command and PowerShells and set bash as the default shell (my preference). If you want to launch a standalone application like git-bash, you will need something else.
As of https://code.visualstudio.com/updates/v1_35 you can now:
select from the pulldown menu directly above the terminal "Select Default Shell"
select the one you like
click the +
done
(the same goes for opening split screen: before this do 1 + 2 and then click the split screen button)
(although overriding the default but does no longer matter if this is your flow)
This can be done by adding a different key at the end. By just changing your example to:
// // 64-bit cmd if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe",
// // 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows2": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
// // Git Bash
"terminal.integrated.shell.windows3": "C:\\Program Files\\Git\\bin\\bash.exe",
Note that the key ...shell.windows is changed to ...shell.windows2 and ...shell.windows3.
Follow-up finding: I've noticed that once restart of the IDE, only the first terminal gets displayed. I had to reopen the settings and save it once to get both the terminals again. Will post if any better solution available.
In the terminal tab, there's a Split Terminal button. Works like a charm
To open the multiple terminal please check the screen shot for the same(on the right bottom of the visual studio code their will be a dropdown and just after it, their is +(plus) icon . On pressing it the new terminal will open.).
The recommended way to automatically open multiple terminal windows is to use the Tasks feature. See Automating launching of terminals in the VS Code documentation.
For WSL Ubuntu on Windows terminal:
File -> preferences -> settings -> click code icon in top right
Enter the following:
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
"git.enableSmartCommit": true
}