DEV Community

loading...
Cover image for Mac commands in VSCode: A requiem for Windows

Mac commands in VSCode: A requiem for Windows

Jill Poole
Miss Maintainer
Updated on ・3 min read

Recently I made the switch from a Windows operating system to a macOS, and while it's probably contrary to popular opinion, I still love and prefer Windows! I grew up on hand-me-down Dell's so I admit, I'm completely biased. I've worked with Macs on occasion for jobs in the past so the switch wasn't a total culture shock, but I never really took to mac's interface, and therefore have never worked with one personally or extensively until a few weeks ago.

Now, in a learning environment riddled with apple products and their seasoned users, I find myself in unfamiliar territory, and showing off my noob-ness when I accidentally still try to use Windows commands out of muscle memory. The most common mistake I make in running commands in Mac is pressing the control button to when I intend to press the command button. In the pressure of the moment, (because of course it always happens when I'm pair programming) I often forget which one actually works for which operating system.

Alt Text

So I came up with a little alliteration to use when these moments happen, to remind me what goes where:

co[n]trols are for wi[n]dows, co[mm]ands are for [m]acs.

Sure it's simple and silly but when I'm trying to think and work fast, this little reminder helps me out! The list of pure mac commands is extensive and of course I still haven't mastered it but to be honest, I do most of my work in VSCode anyway and find myself using keyboard shortcuts (sometimes Windows ones, doh) in that environment all the time, so for my fellow windows users who may have also recently made a switch, I've drummed up this abbreviated list of some of my favorite commands.

wink

VS Code Command Cheat Sheet

This symbol denotes the use of the mac's command button, again, for the seasoned mac user, this is probably obvious and second nature at this point, but after 20+ years of working on PC's, this is something that trips me up often.

Code Editing

⌘X: Cut (+ Shift for individual character/ line control)

⌘C : Copy (+ Shift for individual character/line control)

⌘S : Save

⌘/ : Comment out an entire line or create a line comment
(+ Shift over multiple to comment out multiple lines at once)

⌘L : Select an entire line

⌘D : Select every word in the file that matches current line input

File Navigation

⌘F : Pops open a text bar to (F)ind the searched text in a file

⌘X + Up Arrow / Down Arrow : Jump to the Top/End of a file

⌘ Backslash : Hide/Show Side Explorer Navigation

control + BackTick : Hide/Show Terminal

⌘P : Quick Navigation (Drop Down Nav that lists all files)

⌘ + Shift + P : Opens the Command Palette

⌘K: This one is really cool because it's designed to wait for a second command called a chord.

These are some of my favorite ⌘K combos:

⌘K⌘T : Opens the theme list to allow for a quick change of editor view

⌘K⌘X : Trims all the trailing white spaces. I love this command. If you're like me and struggle with formatting, this one is super helpful when linting your files.

⌘K⌘Z : Toggle Zen Mode

⌘K⌘S : If all else fails and you still find yourself using Windows commands, this handy shortcut lets you change commands to be what you want!

Alt Text

I wrote this because I often work with Mac users who I chuckle with when I stumble over keyboard shortcuts. While I may be incredibly fond of PC's, I also consider it a wonderful skill to be able to utilize a myriad of tools as a fullstack software engineer, shortcuts being one of them.

Keyboard shortcuts are important for productivity on any operating system, by leveraging them we optimize our own performance which in turn can even have an impact on the quality of our code. The longer we can keep our hands on the keys, the more successes and failures we can work through in a shorter amount of time.

Do yourself and your fellow co-workers a favor and get comfortable with keyboard shortcuts, (even if it means 'importing' some commands from another OS!) doing so will help ease the iteration towards the final goal.

Thanks for reading!

Alt Text

What are some of your favorite keyboard shortcuts to aid in productivity?

Discussion (7)

Collapse
mjsarfatti profile image
Manuele J Sarfatti

I'll add 2 shortcuts I find myself using all the time:

⌘+/: Comments/un-comments selected lines
⌥+⇧+F: Auto-formats the document

Collapse
jillianntish profile image
Jill Poole Author

I love the auto-formatter command!! A few of my instructors have teased me about using it instead of my linter but even that can take longer right?! When it's crunch time this is a definite go-to as well

Collapse
mjsarfatti profile image
Manuele J Sarfatti

Well, instead of using a linter (such as eslint), it's recommended to use a formatter (two of the most used ones are prettier for JavaScript, TypeScript, JSON, CSS; and phpfmt for PHP. The reasone is that they assolve two slightly different roles.

In 99% of my projects I have a linter to protect me from syntax errors, and a formatter to beautify my code whenever I hit Cmd+S.

Sometimes I want to format the document but not save it yet, and that's when I use Alt+Shift+F.

Nothing is slower or takes longer though, the formatter takes literally less than the blink of an eye to do its work!

Collapse
metalmikester profile image
Michel Renaud

I've had a Mac at home for nearly 8 years (PCs before that) and still struggle with the keyboard, especially when the shortcuts are displayed using the symbols as opposed to the name of the keys (Ctrl, Option, Command). Basically, it's a lot of cursing every day. I just can't mentally map the symbols to the actual keys (my keyboard, a Das Keyboard for Mac, doesn't have the symbols on the keys).

Collapse
jillianntish profile image
Jill Poole Author • Edited

I know exactly what you mean, the symbol that looks looks likes an escalator gets me every time😂

Collapse
metalmikester profile image
Michel Renaud

I can't even tell you what it does. I've been meaning to tape a "legend" to my monitor but, as the undisputed King of Procrastination(TM), I haven't done it yet.