I gave a presentation at the Atlanta PowerShell User Group meeting yesterday (May 16, 2017) on Visual Studio Code and Powershell. Included below is the document I used for the presentation. I have included it for your reference.
PowerShell and Visual Studio Code
- An Expert’s Guide to Visual Studio Code
- Visual Studio Code
Visual Studio Code
What is Visual Studio Code
Very special thanks to:
- https://twitter.com/daviwil“>@daviwill – PowerShell Team member and Primary author of the PowerShell Editor Services and PowerShell plugin for Visual Studio Code.
Why Visual Studio Code
- Cross Platform – Runs on Windows, MacOS, and Linux
- Community Support –
- Active Development –
- Not just a PowerShell Editor. Supports many many languages.
But what about the ISE?
The PowerShell ISE has been the official editor for PowerShell throughout most of the history of Windows PowerShell. Now with the advent of the cross-platform PowerShell Core, we need a new official editor that’s available across all supported OS platforms and versions. Visual Studio Code is now that editor and the majority of our effort will be focused there.
However, the PowerShell ISE will remain in Windows supporting Windows PowerShell with no plans to remove it. We will consider investing effort there in the future if there is a high demand for it, but for now we think that we will be able to provide the best possible experience to the PowerShell community through Visual Studio Code. (https://blogs.msdn.microsoft.com/powershell/2017/05/10/announcing-powershell-for-visual-studio-code-1-0/“>Announcing PowerShell for Visual Studio Code 1.0!)
- Summary: ISE won’t be going anywhere but don’t expect any new features!
Why not Visual Studio Code?
- No #region support
- Code Folding
- multi-line commands?
Which version of Visual Studio Code is right for you?
- Stable – Mature version and thoroughly tested. Monthly updates.
- Insiders – Daily build for early adopters with the latest changes and bug fixes.
- You can run both versions at the same time.
Personal Setup: I have both versions installed with the Insiders build as the primary version I use. I will tend to use stable for normal tasks and Insiders for elevated tasks.
Starting Visual Studio Code
Usage: code.exe [options] [paths...] Options: -d, --diff Open a diff editor. Requires to pass two file paths as arguments. -g, --goto Open the file at path at the line and character (add :line[:character] to path). --locale <locale> The locale to use (e.g. en-US or zh-TW). -n, --new-window Force a new instance of Code. -p, --performance Start with the 'Developer: Startup Performance' command enabled. --prof-startup Run CPU profiler during startup -r, --reuse-window Force opening a file or folder in the last active window. --user-data-dir <dir> Specifies the directory that user data is kept in, useful when running as root. --verbose Print verbose output (implies --wait). -w, --wait Wait for the window to be closed before returning. --extensions-dir <dir> Set the root path for extensions. --list-extensions List the installed extensions. --show-versions Show versions of installed extensions, when using --list-extension. --install-extension <ext> Installs an extension. --uninstall-extension <ext> Uninstalls an extension. --enable-proposed-api <ext> Enables proposed api features for an extension. --disable-extensions Disable all installed extensions. --disable-gpu Disable GPU hardware acceleration. -v, --version Print version. -h, --help Print usage.
Navigating the User Interface
” alt=”layout” />
- Activity Bar – Located on the far left-hand side, this lets you switch between views and gives you additional context-specific indicators, like the number of outgoing changes when Git is enabled.
- Source Control
- Side Bar- Contains different views like the Explorer to assist you while working on your project.
- Editor – The main area to edit your files. You can open up to three editors side by side.
- Panel – You can display different panels below the editor region for output or debug information, errors and warnings, or an integrated terminal.
- Status Bar – Information about the opened project and the files you edit.
” alt=”CommandPalette” />
” alt=”KeyBindings” />
The following is how I set up my environment for me. Your mileage may vary but you might find some valuable ideas.
- Powershell – The one extension you must absolutely have.
- Settings Sync – Highly recommended if you use VSCode on multiple machines. Also useful if you want to keep history of your settings.
- FontSize Shortcuts – Useful for demos
- Gist Extension
- Git Lens – Very Powerful Git tool
- gitignore – Easily create .gitignore files for your projects
- Identicator – Helps identify current code (indent) depth.
- Sapphire Theme – I have settled on this as my personal theme
- Sublime Text Keymap – I came from using Sublime Text so this makes the transition easier. There could be a key map for whatever editor you are coming from.
- TODO Parser – I love this extension because it allows me to put TODOs in my code and review them.
- vscode-icons – Easily identify your filetypes based on the icons.
Plaster is a template-based file and project generator written in PowerShell. Its purpose is to streamline the creation of PowerShell module projects, Pester tests, DSC configurations, and more. File generation is performed using crafted templates which allow the user to fill in details and choose from options to get their desired output. https://github.com/PowerShell/Plaster”>https://github.com/PowerShell/Plaster
While Plaster does not rely on Visual Studio code for its operation it does provide a very valuble benefit and showcases some of the features of Visual Studio Code and PowerShell.
- My collection of Plaster template(s) are hosted https://github.com/PowerSchill/PlasterTemplates“>here
Where to get help and ideas or contribute?
- PowerShell Slack Team
- #Atlanta – Our own channel for discussions
- #editors and #vscode for Visual Studio Code related discussions
- 50+ different channels on many different topics
- Go to http://slack.poshcode.org/“>http://slack.poshcode.org/ to get an invitation!
- #PowerShell on https://webchat.freenode.net/“>FreeNode
- Also mirrored to #irc-bridge on Slack
- PowerShell plugin for Visual Studio Code https://github.com/PowerShell/vscode-powershell“>Github page
- PowerShell Editor Services https://github.com/PowerShell/PowerShellEditorServices“>GitHub page
- Plaster https://github.com/PowerShell/Plaster“>GitHub page
- https://github.com/Microsoft/vscode-tips-and-tricks“>VSCode Tipsa and Tricks