r/PowerShell • u/mikefrobbins • Aug 25 '17
How to install Visual Studio Code and configure it as a replacement for the PowerShell ISE
http://mikefrobbins.com/2017/08/24/how-to-install-visual-studio-code-and-configure-it-as-a-replacement-for-the-powershell-ise/4
u/lostmojo Aug 25 '17
I can work in code but I find it much more cumbersome than the ise for launching code to test or a lot of the features Tobias has added in steroids. I will work in it some more but it feels like it is lacking some common sense in usability and feature that would be nice to have.
4
u/halbaradkenafin Aug 25 '17
I believe Tobias and David Wilson are discussing bringing some of the steroids features to PS editor services, which is what VS Code uses.
3
u/lostmojo Aug 25 '17
That would be amazing. I have been using steroids for a long time and Tobias was amazing to work with when I ran in to some bugs in early versions of Windows 8, and 10. IMO he has done a great job extending the ISE well beyond its normal limits and make it a really useful tool for my type of work.
3
u/halbaradkenafin Aug 25 '17
Yeah, I really liked ISE Steroids when I used it for a few months. I didnt use every feature so it was less of a hit for me to swap to VS Code.
1
u/lostmojo Aug 25 '17
How do you handle running test code in vscode? I hate that (last time I used it at least) it was inconsistent on displaying the output of the run to the console and it was really tough to read through a lot of output.
1
u/halbaradkenafin Aug 25 '17
I'll admit it's not great for that but if I'm running a lot of tests I'll generally make the console bigger and just scroll to any failed tests. I don't really care about passing tests and usually have all the verbose/warning output mocked anyway in case the code I'm testing has those outputs in it.
4
u/2boxenofdoughnuts Aug 25 '17
I use VS Code almost exclusively for PoSH coding but the only thing I'm not a fan of is the intellisense tends to be buggy. I have to save the file as a .ps1 before it will pick up that it's PoSH (makes sense but still an extra step) and when it does pick it up, the tab completion doesn't allow scrolling (i.e. I can't hit tab multiple times to scroll through possible options. Have to use their drop-down or use more characters so the option I want is the only option). You get used to it but there's somethings that could be a bit more fluid.
I never used the built-in terminal on ISE (prefer CorEmu) so I can't speak to how well the terminal output works.
We're starting to get into using source control via GitLab soon so I'm interested in how the workflow is within VS Code.
11
u/alinroc Aug 25 '17
I use VS Code almost exclusively for PoSH coding but the only thing I'm not a fan of is the intellisense tends to be buggy. I have to save the file as a .ps1 before it will pick up that it's PoSH (makes sense but still an extra step)
If you set your default lanugage to PowerShell the "have to save it first" will be fixed. Add this to your settings:
"files.defaultLanguage": "powershell"2
u/Sheppard_Ra Aug 25 '17
This and the tip I posted were literally in the video, heh.
1
1
u/silentmage Aug 25 '17
I have this set and it never takes effect
{ "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe", "workbench.colorTheme": "PowerShell ISE", "files.defaultLanguage": "Powershell", "editor.formatOnType": true, "editor.formatOnPaste": true }4
5
u/Sheppard_Ra Aug 25 '17
I have to save the file as a .ps1 before it will pick up that it's PoSH (makes sense but still an extra step)
In the bottom right where there's a spot where it tells you the file type you're working in. Click on it and choose PowerShell. Now your 'Untitled' tab will be formatted as PowerShell without having to save it as a ps1.
2
Aug 25 '17
I have to save the file as a .ps1
then add this to your vscode settings.json
"files.defaultLanguage": "powershell"2
u/-partizan- Aug 25 '17
Hit f1 to pull up the command palette, search for "change language" and choose Powershell. No need to save.
2
u/atrca Aug 26 '17
For intellisense in some aspects it seems more intelligent and in others it doesn't. Maybe I've just never noticed this but like when I'm typing stuff and saving it to a variable. When I go to use that variable it already has the members listed like it identifies the "type" which I like. It feels more like when I code in c#. I feel like in ISE you don't get that until you've run the code once and the variable has been "initialized".
But then with tab completion in code I feel like when I hit tab it won't always give me the cmdlet/variable/parameter it will give me a literal tab even when I had the term selected.
I'm really liking VScode though. The syntax highlighting seems to go crazy in pipelines. I would like to be able to open the terminal full screen as like a tab at times. From what I read a "tab terminal" is not planned. I enjoyed the quick switch from full script to full terminal in ISE.
1
u/jasred Aug 25 '17
I never used the built-in terminal on ISE (prefer CorEmu)
You mean ConEmu, right?
1
u/2boxenofdoughnuts Aug 25 '17
Yup, sorry about that. ConEmu. Wanted something with tabbed windows that recognized PoSH intellisense. I use MobaXterm for most everything else but it doesn't handle PoSH that well IMO.
3
u/Qel_Hoth Aug 25 '17
Just started using VS Code and I really like it, having one issue though.
It doesn't seem to want to tab-complete variables in a string, is there any fix for that?
0
Aug 25 '17
[deleted]
1
u/Qel_Hoth Aug 25 '17
Thanks, already an issue opened, it looks like Intellisense isn't automatically invoked on statements inside quotes. Ctrl+Space will manually do it.
2
u/CobbITGuy Aug 26 '17
I've been using it for a week, but an annoying feature on my setup is that the ExecutionPolicy for Process is set to RemoteSigned in VSCode. It's Unrestricted in the terminal and ISE. Since I save all my scripts on a network share I have to go into the integrated shell and type in a Set-ExecutionPolicy... command before I do any debugging. Perhaps I'm missing something obvious, but I've only been using PS and VS Code for a week.
2
u/Taoquitok Aug 26 '17 edited Aug 26 '17
I think you either need to create a $profile file and add the set-executionpolicy there, and/or you need to add the below value to your VSC profile so it'll load the existing profile:
"powershell.enableProfileLoading": true,
3
u/CobbITGuy Aug 26 '17
From inside the integrated shell in VS Code I ran the $profile command to get the path to the expected profile file. I created the file and added the Set-ExecutionPolicy command there and it worked. Thanks for your help.
1
u/chreestopher2 Aug 25 '17
you currently cant, at least not to the same level of responsiveness and reliability.
I got excited when jetbrains just released their .net flavor of intelliJ ... but it doesnt yet have powershell support even on the roadmap of intended features
If jetbrains were to put serious effort into Powershell, to even a 10th of the level they put into the other languages they target with intelliJ ... it would be unbeatable.
edit: but they wont, because powershell doesnt have anywhere near as many people who just do powershell as the other languages jetbrains creates products for.
1
u/stigansky Aug 26 '17
I use VS Code for almost everything except PowerShell. Mostly because I really don't like its PowerShell syntax highlighting. And unlike ISE, it just doesn't feel native (integrated) to me.
1
u/majkinetor Aug 27 '17
The fastest way to install and keep it updated via choco:
cinst visualstudiocode
code --install-extension ms-vscode.powershell
14
u/Semt-x Aug 25 '17
I tried VSCode as a replacement for ISE in last couple of months. these are my findings:
built-in code review was helpful
replace all variable names at once (ctrl-f2) was useful
dark theme looks sleek, is nice on the eyes for me
use of built-in aliases are marked as a problem, there's no way to allow these
terminal output is buggy, only showing part of the output.
clear (clear-host) did not clear the terminal output. ctrl-K did, couldn't find a command to that from within a script.
F5 runs it with debugging, not just runs it. that confused me when I started to use it.
I'm really curious if I missed some killer features.