Integrating Visual Studio Code into Cygwin - visual-studio-code

I was wondering if there was a way to have Visual Studio Code open a file when accessed by Cygwin. For instance, when using an alias to change directories and open a Verilog file, have that file be opened within Visual Studio Code instead. I have very limited experience in Linux, and it looks like Visual Studio Code is easier to navigate/edit scripts, though that could be wrong.

One way to open a windows command (that is not in the path) from the cygwin terminal is to create an shell alias to start VSCode or Visual Studio with a filename from the cygwin terminal. Add a line to your .bashrc like:
alias vscode=<path to vscode>
Find <path to vscode> by right clicking on the link you use to open VSCode or Visual Studio using the desktop or start menu, and select "More -> Open file location". This will open an explorer window with a shortcut highlighted. Right click on it, and select "Properties". In properties click on the "Open file location" button. In the resulting explorer windows, use shift-right click on the highlighted file and select "Copy as path".
Back in cygwin, enter
cygpath -wa <paste>
(In the cygwin terminal, use "Right click -> Paste" or shift-ctrl-C to paste). Then use line editing to change the double quotes to single quotes and run the command. This shows you the string to use as <path to vscode> in the alias command. You must restart the cygwin terminal for the alias to be available.
To use this alias, enter e.g.
vscode <filename.ext>
to open the file is VS Code or Visual Studio. I use similar alias to open an explorer window, or my browser with an html file, or to open a file in Notepad++.

Related

How can we add existing file to VS code solution, I am not getting 'Add existing item' option

Can we add existing file or folder to VS code solution from explorer itself ?
One way is to add from file explorer but can this be done from VS code explorer itself like other Visual studio IDE solution explorer ?
We can't add it like Visual Studio IDE as how you will always have a link to it.
However, you can "Open" a file temporarily via Cntrl+O or can open a new Window with that other folder opened.
On Linux, the existing file can be inserted by copying to system's clipboard then paste from VSC.
To copy to system's clipboard:
xclip <filename>
Then paste to VSC as usual using Ctrl-V.

How do I open the 'launch.json' file in Visual Studio Code?

I am a new programmer that started learning Python, but there's something bothering me which I'd like to change.
As I've seen that it is possible to remove the unwanted path from the terminal when executing code, I cannot figure out how to access the Visual Studio Code launch.json file and all of the explanations on Google are quite confusing.
Note that if Visual Studio Code hasn't created a launch.json file for your project yet, do the following:
Click the Run | Add Configuration menu option, and one will automatically be generated for you, and opened in the editor.
NOTE: You have to have a "Folder" open, for this to work. File | Open Folder...
In Visual Studio Code, use shortcut Ctrl + Shift + P to open the Command Palette and type Open launch.json. And it will open the launch.json file for you. If you also can't open launch.json then try the way below.
Check if the .vscode folder exists in the root folder. If not, then create a new one and create file launch.json in that. Now you have launch.json for your workspace and you can configure your project.

Open folder in Explorer from VS Code

Say I have a project/folder open in VS Code and I want to open the folder in Windows Explorer, is there keyboard shortcut or a VS Code Extension for that? Sometimes I also need to go to the project folder in command prompt.
In Visual Studio 2017, there's a menu option to open the folder and an extension for quickly getting to the project folder in command prompt -- see below:
How do I handle these in VS Code?
Right click on a file or folder from the left side explorer of VSCode, then select "Reveal in Explorer". Now you can see the folder in windows explorer.

Visual Studio Code in Explorer's context menu

I want to be Visual Studio Code my default editor for all text-based file types in Windows. For Notepad++ there is an extension in the Windows Explorer to provide "Edit in Notepad++" for each file.
How can I achieve this for "Edit with Visual Studio Code"?
Do I have to "program" such extension on my own or are there any ready-to-use solutions available?
According to this blog post you can set this option during the installation process. If you want to add this option afterwards you either can follow the instructions of the rest of the post or (as recommended) reinstall vscode and then select that option during reinstalling.
When I faced the same issue, for me it was more comfortable to simply reinstall vscode.
It is east !
step 1 -->
Right click the file you want to always open with VS code
example - if you want to always open .txt files in VS code then Right click on any .txt file that is in you system
see this
step 2 -->
click on 'open with'
see this
step 3 -->
click on 'choose another app'
see this
step 4 -->
a new window will open, it will show all the applications on you system that are capable to open that file
click on VS code
and check the box at the bottom that says 'always use this app to open .txt files'
see this
and then click on open
THATS IT
NOW ON .txt FILES WILL BE OPENED IN VS CODE
.txt file extension is just an example, you can do this to any file example .py, .html, .pdf etc.

Use an external editor for some file types with Netbeans

So with eclipse I would instruct it to open html/css/js files in textmate, and pretty much just use if for the php side of things.
Would like to do a similar thing with nb if possible.
Any thoughts?
Best,
Bob
There exists a Path Tools plugin for Netbeans. It has a command "Edit path...". With this you can select a file in the tree, click "Edit path..." and the file will be opened in an external editor.
You can customize the external program which is called under "Tools" -> "Options" -> "Miscellaneous" -> "Path Tools" -> "Edit Commands For File" .
You can't assign it to specific file types, but at least you can open files without leaving Netbeans.
The webpage of the Path Tools plugin looks not very active, but it works in Netbeans 6.9.1 without problems (Works on My Machine).
It also has other useful actions:
Copy Paths Action Copy the full paths of the files/folder of selected node to the clipboard.
Explore Action Launch the OS File Explorer
Shell On Path Action Launch the OS shell
Edit Action Launch the editor
This plugin should be integrated to Netbeans.
Thank you for the help on this.
Here is a way for the Path Tools 'Edit' toolbar button to pop up the Windows 'Open With...' dialog box for the selected file.
In Options, Path Tools... 'Edit Commands' 'For File' - change the command to this:
rundll32.exe C:\WINDOWS\system32\shell32.dll,OpenAs_RunDLL {path}
(Edit: I forgot to say this is for XP - idea is the same for newer Windows)
If you don't want to deal with manipulating plugins and configs, you can do it this way (valid for version 8.2):
Go to Tools > Options > Kepmap
search for "path"
It defaults to Alt + Shift + L
use that command in any editor window to get the path for the file, then simply open that path in whichever editor.
I agree it's not as smooth and savvy as having a readily-available "open in external editor" command, but it's almost there.