Automatically Open Terminal on start OR New Window - visual-studio-code

Simple question: 99% of my time spent in VSCode is spent with a terminal open. Is there a setting or an extension that will keep terminal open when I either
A. Start VSCode
OR
B. Open a file / folder in a new window

Are you aware of batch files?
Create a text file with the extension .bat and insert this code to make it open both programs with one user action. Do change the Visual Studio path so it matches your executable location; the example is generic.
start cmd && "C:\Users\{UserName}\AppData\Local\Programs\Microsoft VS Code\Code.exe"

Related

How do you select the terminal location for every terminal type in a VS Code workspace?

I am working in a VS Code workspace with multiple directories. When I open the default terminal (Powershell) it get a prompt asking which of the directory roots I want to open the terminal in.
However, if I open another terminal from the dropdown, it opens at the root location of whichever file that I am currently displaying.
Is there a setting to show this prompt for every new terminal, not just the default one? Specifically for the WSL terminal.

How to change folder that opened by default in VSCode?

I have small problem with VSCode folder, that opened by default.
Problem description: I start new instance of VSCode (trough File->New Window), and then if I choose File->Open Folder it opens dialog with my Windows user folder as starting point (C:\Users\MyUser)
Question: How can I change that folder in settings (if it possible)? So by default it will show as start point for example D:\development\ ?
At the time I write this answer, this is not possible. There are two problems on Windows, and one problem on Mac and Linux:
VS Code does not provide a default path to the file dialog 1. It does remember the last folder that you opened a file in, but that path cannot be used as a default because it is overwritten constantly.
On Windows only, Electron ignores the default path when creating a file dialog if the default path is a directory 2.
An extension also cannot solve this, because extensions are not allowed to modify the File menu 3.
I think the best option at this point is to pin a folder to the Quick Access area in Windows Explorer, as suggested in a comment, or to put an actual shortcut in the user profile folder.
Workspaces and File > Open Recent may also be helpful if you often open the same folders.
Your main problem is that you are unable to open your specific folder in VScode.
To solve that you can simply open the terminal/cmd in that specific window by just typing cmd in your search bar or just by pressing shift+right-click in that folder.
Now your cmd is open and you just have to type "code ." in the cmd and press enter to open the current folder in your VSCode.
In case that code . doesn't work for you then you have to add the Vscode in the environment variables of your windows.
Visual Studio doesn't provide a specific feature to open a specific path. But there is a solution to your problem. You are saying that you want D:\develpment as a default when you open VS Code. You can go to that specific directory or create shortcut to desktop then click right click on that folder and then click on open with code. If you didnot see open with code then reinstall your VS code and check on open with code when you are reinstalling VS Code.
make a shortcut on the desktop for vscode and then modify it and add the folder after the .exe command. This will default open that folder when you double click on it.
Visual Studio Code can be installed in two ways - User setup and System setup. I strongly believe you have User setup installed in your PC. Try re-installing it System-wide. That should probably fix your problem.
For more information: https://code.visualstudio.com/docs/setup/windows#_user-setup-versus-system-setup
PS: A lot more information is needed, you can share a screenshot of the window and elaborate more on it.

Open file from integrated terminal in VS Code

I have VS Code setup with WSL on my Windows 10 machine. I am trying to find the command I can use to open an existing file from the integrated terminal in the current VS Code window.
I tried code filename, which launches a new VS Code window. I tried with code -r filename, but it also launches a new window.
Is there a way to quickly open a file when I'm focussed on the terminal?
As of version 1.43.1, this appears to now work as expected, without additional add ons.

Open a file in VS code using `open -r`

I was trying to use the command code -r file_name.py in the integrated terminal in VS code to open the file in the existing window that I'd already opened. However, another new VS code window was still generated. What's weird is that originally, I could open a file by simply using code file_name.py without using the -r flag. Is there any way to solve the problem? I want the file to be opened in a new tab in the same window instead of in a new window. Any experience shared will be appreciated!
When using VS code the correct command to open a file in an existing code window is indeed code -r .\file_name.py, if you are doing so from a terminal within VSCode it will do so within that instance of VSCode.
My instance of VSCode defaults to using CMD on Windows 10 for this command. What are you using to run this command?

VSCode Win Shortcut to Launch with Open Folder Command

I have 10 applications that I constantly work on. At times I need to open them all up separately to run bash commands on them. Is there a way I can create a windows shortcut for each folder, then I select all 10 shortcuts and click enter to initiate 10 different VSCode applications each opens up with their respective folder I set to?
(Windows 10) To open VS Code in desired directory using shortcut:
Create shortcut to Visual Code Studio app,
Right click on the shortcut and select Properties,
In Target field append your directory path (remember to use quotes " " if there are spaces in the path).
ctr + K + O
open a folder vs code most common shortcut key available all platforms same
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
I use a batch file like in Sean's solution. You can automatically close the terminal after launch if you use the start command rather than "code ."
Here's an example:
#echo off
cd "C:\path\to\your\project\folder\"
start "" "C:\Program Files\Microsoft VS Code\Code.exe" .
exit
Note: if you don's like how the batch file looks, you can make a shortcut to the batch file and change the shortcut's icon to the VS Code icon.
In a similar situation, I use a batch file to launch my most used vscode windows. I am not yet smart enough to make the cmd windows disappear after they open vscode, but maybe someday. In each batch file, use the following changing the directory for each project.
#ECHO OFF
cd C:\directory\where\your\project\is
code .
exit