Tim D'Annecy

vscode

#VSCode #PowerShell #Windows

I love VS Code. It's got all of the features and tools that I need for coding and testing.

When I'm working on a file in the Editor pane and I want to run it or test a command in the Integrated Terminal, I have to manually navigate to the folder where the with a series of cd commands and Tab autocompletes.

If I exit or restart the Terminal, the working directory switches back to the root of my workspace and I have to repeat the process over again.

I have to deal with this annoying quirk dozens of times during the day and it gets very repetitive to keep typing cd.

To make my life easier, I added the keyboard shortcut Ctrl+Alt+c on my Windows machine to change the Integrated Terminal's working directory to the folder of the file I'm currently editing. This shortcut basically sends the command cd 'directory of the current file' so I don't have to keep typing it.

Read more...

#VSCode #PowerShell #Windows #MacOS

I use VSCode for all my coding. One thing I appreciate about the PowerShell module in VSCode is how it recommends best practices inline with my script.

One of the recommended best practices for PowerShell is to use a list of approved verbs that define which words can be used in functions. This makes sense—I love the way PowerShell uses the Verb-Noun structure to keep things standardized and avoid confusion.

Sometimes the recommended list of verbs doesn't include what I'm trying to do, like “Check” or “Verify”. When I write a function using an unapproved verb, VSCode puts an orange squiggly line and these alerts get counted with others that I would consider more important:

This makes my VSCode environment noisy and it can be difficult to sift through all the alerts to try to identify real issues. After some digging, I found a way to hide these alerts without turning off the whole PSScriptAnalyzer feature.

Note: In the code examples, I've removed the signature blocks. Don't change or delete this section in your environment—If you do, you'll need to re-install the PowerShell extension and/or VSCode.

Read more...