Editing WSL config files\code etc with Visual Studio Code, in Windows - visual-studio-code

I am really enjoying WSL and using it for a lot of stuff these days, including my Ansible workstation, also writing a lot more code in it...
Question: I can see where the WSL file system is:
https://askubuntu.com/questions/759880/where-is-the-ubuntu-file-system-root-directory-in-windows-nt-subsystem-and-vice
All of the docs tell you very clearly to stay away from the Linux file system and not to access it from the Windows instance it is running under. Fine. But! I hate to ask redundant question, but I would dearly, dearly love to be able to use full blown graphical VS Code in Windows in my text editor for WSL. Am i missing a trick somewhere for a way to do this without breaking anything?
Apologies for the non question. Hopefully it is allowed.

In vscode...
You can press the green icon bottom-left
This will open the command palette
Choose "New WSL Window"
Open a folder, you will be able to navigate from ~ to choose location in command palette
Once folder is choosen, you're set to go, vscode will display file tree from opened folder and you can do your thing :)

Related

Visual Studio Code terminal displaying "sh-3.2$" every time I "Open in Integrated Terminal" instead of the working directory name (Mac OS)

Earlier today I was having an issue where when I would go to open a new terminal or open a file or folder in Integrated Terminal the terminal would be automatically killed within a couple of seconds without me manually killing it. I was confused as to why this was happening because as far as I could tell I hadn't changed my settings.json file in VS Code or User or Workspace settings and everything was running smoothly just minutes earlier. I was able to resolve that issue but I created a new minor inconvenience. Now whenever I open a file or folder in Integrated terminal it displays "sh-3.2$" instead of the current directory I'm in. If I type pwd and press enter it'll of course display the current directory I'm in but I don't want to have to type that a million times moving forward. If somebody could help me fix this issue I'd greatly appreciate it! I read some of the documentation online but I'm a new bootcamp student and I tried following along but it was going over my head. Thanks again!
I was reading a similar Stack Overflow question and they were saying to try and setup/configure my bash shell to have a prompt with path, specifically the PS1 environment variable, but I was confused on how to actually go about doing that.

VS Code Terminal command extra first letter

In vs code terminal I'm getting first letter of command twice. it's not causing any problem but it's kind of annoys me to watch the wrong command. I'm not writing any letter twice, the first letter of all commands gets repeated automatically.
as you can see there are 2 commands first one ppython first p automatically got repeated even though i wrote python it makes it ppython. and the first p that got repeated won't delete from there even if i spam backspace so many time . the I tried to clear the command till first p and as I'm not able to remove first p from terminal I just wrote ython in front of it. it looks proper now python. but I got a error response as ython is not recognized command. this same happens with other commands too like cd converts to ccd.
Edit : I Re-installed vs code then but that didn't resolved my problem, when I installed it again all my extensions were there already installed then I deleted vs code again then went to the vs code's location there was a folder name .vscode I deleted that then installed vs code again now all the extensions were deleted from vs code but I'm still having the main problem . that doesn't resolved it. and I'm not getting that error while using other terminals like git bash and I'm getting this error only when I open python file's folder not when I open a react app folder or normal js or other language.
I also tried reseting the default setting from setting.json file as one of the answers suggested but that doesn't worked.
It's hard to answer this without knowing your configuration. What plugins have you installed? Try disabling those related to the terminal emulator one by one to see if they're causing any issues.
In doing this, you would naturally restart the terminal emulator as well. If the problem persists, check if you get this erroneous doubling on a terminal emulator outside of VS Code (Terminal or PowerShell).
If nothing works, try reinstalling the interpreter and also VS Code. Especially the latter, if this seems to affect only the terminal emulator within VS Code.
It's really hard to answer your question without knowing your vs code configuration setting.
The easiest way is you can reset your vs code to default
The Steps
Go to View > Command Palette or press Cmd + Shift + P (macOS) or Ctrl + Shift + P (Windows).
Search for open settings json and select Preferences: Open Settings (JSON) which show ups from the result list.
If you’ve been working with VS Code for a while and installed a lot of things and made a lot of changes, you’ll find there’s a lot of stuff in this file:
Delete everything inside the root braces and save the file
Relaunch your VS Code.
(This step is optional) In case you want to not only reset VS Code but also remove all installed extensions:
Delete the ~/.vscode/extensions folder if you’re on a Mac.
Delete the %USERPROFILE%.vscode\extensions folder if you’re using Windows.

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.

What settings do I have to change to make Visual Studio Code automatically run files in the right directory?

Coming from IDLE, I am used to be able to just left-click python files anywhere, it'll launch IDLE, and then pressing F5 just runs the script. In VSCode however, I have to open the terminal, cd into the right directory, and only then can I finally run my python script. Is there a way to change this behavior?
I was recommended to use the Code Runner extention and bound the Run Code (code-runner.run) command to my F5 key.
Then I noticed input() not being ran so I had to make sure code-runner.runInTerminal was on, but that re-started my problem from the beginning because the terminal was at the wrong working directory and then I finally found the code-runner.fileDirectoryAsCwd setting to run it from there.
I think this solution is similar to this one for the python extention, but I'm not sure if that would cause the whole wrong working directory issue again.
choose from menu file then click on auto save

Install VSCode in a specific folder

I just downloaded the Visual Studio Code App from https://code.visualstudio.com/ and when I tried to install it, it simply just installed it by itself, without the option to change the installation path.
I have an external harddrive, which is where I want the IDE to be placed instead of the Local Harddrive. How can I change this?
On the VSCode download page select "System Installer" instead of "User Installer". The System installer will prompt you for the install location.
Full credit to Hans Passant for giving the following working solution as a comment.
The installer does very little beyond copying the files, it just creates some Explorer context menu shortcuts ("Open with Code"). Otherwise following Chromium conventions and copying itself to c:\Users\yourname\AppData\Local\Code\app-0.1.0 so it can update itself without you noticing. Boo. So high odds that simply moving that folder to the other drive works just fine, put it anywhere and create a shortcut to Code.exe. If you still want the context menu entry to work then use Regedit and search for "code\app-0.1.0".