VS Code equivalent to Visual Studio’s Ctrl+m Ctrl+o

Sometimes, when you have a long file, it’s convenient to fold/collapse all the code regions so you can get a big picture of your file. In Visual Studio (the full blown IDE from Microsoft), it’s a simple keyboard shortcut combination

Ctrl+m Ctrl+o

Thankfully, Visual Studio Code has something similar. To fold ALL regions use

Ctrl+k Ctrl+0

Then just use the following to unfold the code file

Ctrl+k Ctrl+j

The nice thing about this is that all the sub regions are folded as well. So you can simply open one region and all the items inside are still folded.

Reference: https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_keyboard-reference-sheets

Install Chrome Extensions in Microsoft Edge

If you are intrigued by the idea of switching from the resource hog that is Google Chrome to the new kid on the block, Microsoft Edge BUT you have some killer Chrome extensions you just can’t live without…Then fear not! You can configure Edge to use a Chrome plug-in.

First, go get Edge. Go on. I’ll wait…

Ok, now that Edge is installed you can add your extensions. First, click the triple dots in the upper right-hand corner. Then select Extensions from the menu.

Edge Options

Before you go to the effort of getting a Chrome extension, first check for the extension in the Microsoft Store (link in the settings). What you want may already be there.

If you don’t find what you’re looking for then toggle the Allow extensions from other stores setting in the bottom left-hand corner.

Then navigate to the Chrome Web Store and search for your desired extension. Click the Add to Chrome button.

Edge will give you a pop-up asking if you want to add the extension, click the Add Extension button.

This will add the extension and you should get a notification that the extension was added to Edge.

Badda-bing, badda-boom! Your Chrome extension should now be installed in Edge and running just like the ones from the Microsoft Store. With full rights and privileges. You can disable or delete them just the same.

One last nice thing Microsoft has done is to segregate the other sourced extensions from those from their own store. That way you can easily find them.

Copy Multiple Items in Visual Studio 2019

As a developer, I have to copy and paste. A lot! Sometimes I need to copy several items from different locations and then paste them into the same file. This can be very tedious with the traditional Ctrl+C then Ctrl+V process. To help remedy this, I use Comfort Clipboard Pro, a very powerful clipboard manager. I realize for some this may be a bit of overkill or they don’t wish to spend the money on a solution.

Thankfully, Visual Studio 2019 has a feature which can help. Simply copy several items in a row using your preferred method — from the file menu or with a key command. Then place your cursor where you wish for the copied items to be pasted. Next, go to Edit in the file menu and select the Show Clipboard History option (alternately you can press Ctrl+Shift+Insert).

Select Show Clipboard History

This will display a popup list of the things you’ve just copied. Click one of the items in the list.

Displays list of clipboard items

The item you selected will be pasted into your file where your cursor currently sits.

Pasted item from clipboard

That’s it! Quick. Simple. It didn’t require any additional software. And it didn’t cost you anything. Hope that helps!

Copy Visual Studio 2017 configuration settings to Visual Studio 2019

Visual Studio 2019
Visual Studio 2019

Visual Studio 2019 shipped on April 1st. And one of the nice things about it is you can have it installed side-by-side with other version — like Visual Studio 2017. Most developers have spent some time selecting which features of Visual Studio they need installed. A nice addition to the new Visual Studio Installer is you can export your configurations from one version and import into another. So, if you’ve just installed 2019 and wish for it to be configured like your 2017 version, now you can! And it’s pretty straight forward.

Launch the Visual Studio Installer.

Click the Modify button next to your Visual Studio 2017 installation.
This will show you the current configuration. You can just close this modal if you don’t wish to make any changes.
Click the More drop down and then select Export configuration from your 2017 installation.
Choose a location on your system where you wish to save the configuration file.
You will then see all the current settings and give you one last change to make changes. Then click the Export button.
A confirmation message will display when exporting is successful.
Next, click the More drop down for your 2019 installation then click Import configuration.
Locate your configuration file you just exported.
It will display the configuration options which will be imported giving you a chance to make any changes. Then click the Modify button to make any changes to your 2019 installation.

And that’s it! The installer will download and install any needed components based on your older configuration file.

How to check which version of .Net Core you have installed.

Open a command prompt and enter the version command.

dotnet --version
dotnet version

This should return a version number. If you get something like the message below, .Net Core is not installed.

'dotnet' is not recognized as an internal or external command,
operable program or batch file.

You can also issue the info command to get a lot more information about your environment.

dotnet --info
dotnet info

If you want to actually look at the different .Net SDKs which you have installed, they can be found here on a Windows machine:

C:\Program Files\dotnet\sdk

JavaScript — Get the Currently Focused Element

In JavaScript, the currently active element is said to have Focus, which means it’s the element being acted upon. Like a form field in which you are typing is said to have Focus.

You can get the currently focused element with a simple reference on the Dom:

var currentElement = document.activeElement

This will return the element which has focus, or null if there is no focused element. It will let you have access to the whole element. You can get to any properties on that element like the Id or Name. The CodePen below is a simple example of using the document.activeElement


See the Pen Get Focused Element by Chris (@cgreenws) on CodePen.

For more information:

JavaScript — How to use the Set object

JavaScript has an object called Set which will store any type with unique values — this can be a primitive value type (e.g. string, number, boolean, null, undefined, symbol) or even an object reference.

//create a new Set
var setA = new Set();
//use .add() to add types to the set
setA.add(6); // Set is [6]
setA.add(9); // Set is [6,9]

//or create a Set by passing it an iterable object
var setA = new Set([6,9]); // Set is [6,9]

Because a value in a Set may only occur once, it will eliminate duplicates when you add them.

//Eliminates duplicate values on creation
var setB = new Set([6,7,8,9,6,7]); // Set is [6,7,8,9]

//Doesn't add new values if they already exist in the set
var setB = new Set();
setB.add(6)// Set is [6]
setB.add(7)// Set is [6,7]
setB.add(8)// Set is [6,7,8]
setB.add(6)// Set is [6,7,8]
setB.add(9)// Set is [6,7,8,9]
setB.add(7)// Set is [6,7,8,9]

Use the .has() method to check if a value is in the set. It will return a boolean of True or False depending on if it finds the value.

var setA = new Set([6,9,3,5,8]);
setA.has(5); // true
setA.has(2); // false

The .delete() method will remove a value from the set. It will return a boolean value if it found the value in the set.

var setA = new Set([6,9,3,5,8]);
setA.has(5); // true
setA.delete(5); // returns true
setA.has(5); // false -- Set is now [6,9,3,8]
setA.delete(5); // returns false

You can also remove ALL the values in the set with the .clear() method.

var setA = new Set([6,9,3,5,8]);
setA.has(5); // true

A Set does not have a Length property but it does has a Size which will tell you how many values are stored in the Set.

var setA = new Set([6,9,3,5,8]);
setA.size; // return 5
setA.length; // returns undefined

To keep the Set similar to the Map object, values are stored as a key/value pair where the key is the same as the value. You can retrieve all the values in a Set using the .entries() method. This will return an Iterator of all entries in a format of [value, value].

var setA = new Set([6,9,3,5,8]);
var myEntries = setA.entries();

You can also just get the keys or values for a Set using the .keys() or .values() methods, respectively. Both return a new Iterator object. Since the value is used as the key in a Set, both methods ultimately return the same result.

var setA = new Set([6,9,3,5,8]);

var setKeys = setA.keys();
// or
var setValues = setA.values();

Because a Set is an iterable object, you can use the .forEach() method to loop over the values in a Set. You can pass a call back function in as a parameter which will get called once for each value in the set. It also has an option argument which can be passed that will be used for the this value for each callback.

var setA = new Set([6,9,3,5,8]);

setA.forEach(function writeValue(value) {

// 6
// 9
// 3
// 5
// 8

// example passing 'a' as the thisArg to the forEach
setA.forEach(function writeValue(value) {
     console.log(value + '---'+ this );
}, 'a');

// 6---a
// 9---a
// 3---a
// 5---a
// 8---a

If you just want to iterate over the values in a Set, you also have the option of using a For loop.

var setA = new Set([6,9,3,5,8]);

for (let item of setA) {
// or 
for (let item of setA.values()) {

// both output
// 6
// 9
// 3
// 5
// 8

You can easily convert from a Set to an array using Array.from() method.

var setA = new Set([6,9,3,5,8]);

var array1 = Array.from(setA); // [6, 9, 3, 5, 8]

//you can also use the Spread Syntax to create the Array of Values
var array2 = [...setA]; // [6, 9, 3, 5, 8]

One neat trick you can use Set for is to de-dupe an Array.

var array1 = [6,9,3,5,8,9,4,2,1,2,2]

var setB = new Set(array1);

var array2 = [...setB] //[6, 9, 3, 5, 8, 4, 2, 1]

// or you can simplify things like so
var array3 = [...new Set([6,9,3,5,8,9,4,2,1,2,2])]; 
//[6, 9, 3, 5, 8, 4, 2, 1]

Another is to use Set as a way to break a string apart to it’s individual unique letters.

var myString = 'Hello';

var charSet = new Set(myString); // ["H", "e", "l", "o"]
charSet.size; //4

//just keep in mind that case sensitivity counts
var myString2 = 'HeLlo';

var charSet2 = new Set(myString2); // ["H", "e", "L", "l", "o"]
charSet2.size; //5

There are a couple things to keep in mind. A set can only contain unique values. When you interate over a Set object, it returns the values in insertion order (how they go in is how they come out).

Objects can be a bit confusing at first compared to primitive types. For instance:

var obj = {'a': 1, 'b':2}
var obj2 = {'a': 1, 'b':2}
var mySet = [{'a': 1, 'b':2}, obj, obj2]

// mySet now contains
// [{'a': 1, 'b':2}, {'a': 1, 'b':2}, {'a': 1, 'b':2}]

How do I duplicate a line within Visual Studio Code?

If you want to easily duplicate a line of code in Visual Studio Code, you can do it with a simple keyboard shortcut. Just use the Copy Line Down (Ctrl+Alt+UpArrow) or Copy Line Up commands (Ctrl+Alt+DownArrow) — depending on where you want the new line inserted with respect to your cursor.

VS Code Short Cuts

You can view all the shortcuts like this in Visual Studio Code by going to the preference settings found at

File > Preferences > Keyboard Shortcuts

If you want to easily duplicate a line of code in Visual Studio Code, you can do it with a simple keyboard shortcut. Just use the Copy Line Down (Ctrl+Alt+UpArrow) or Copy Line Up commands (Ctrl+Alt+DownArrow) — depending on where you want the new line inserted with respect to your cursor.

JavaScript — Loop Over an Array with forEach() Method

You can use the forEach() method to loop over an array and execute a function on each element of the array.

var pets = ['dog', 'cat', 'monkey'];

pets.forEach(function(element) {

// expected output: "dog"
// expected output: "cat"
// expected output: "monkey"

For more information: