DEV Community

loading...
Cover image for Mac Keyboard Shortcuts Every Dev Should Know

Mac Keyboard Shortcuts Every Dev Should Know

torianne02 profile image Victoria Crawford ・6 min read

Something that has always interested me is the impact that small actions have on our daily lives and I think knowing keyboard shortcuts is one of those actions. Why? It saves you time. Yes, only a tiny fraction of time but all those tiny fractions add up in the end. Keyboard shortcuts can also give off the impression that you are confident in what you are doing, which is a huge plus.

My Story with Keyboard Shortcuts

Before I started programming I had no idea how to use any keyboard shortcuts. It was through programming, and my insistent fiancé, that I began to learn how to navigate around my computer while rarely touching my mouse/trackpad. He used to get so frustrated with me when I'd ask him a question while coding and I'd use the trackpad of my laptop to navigate through open windows or to select a word. Why would he get mad? Well, I was sort of wasting his time. Using keyboard shortcuts creates a quicker way to navigate your laptop/computer than constantly pulling back and using your trackpad/mouse.

Since gaining this skill I feel as if I have gained the tiniest semblance of confidence in my demeanor at work and during interviews. This skill has helped me combat the good 'ole fight with imposter syndrome, because it has given me a sense of "I know what I'm doing."

Anyways, that's enough about me. Let's dive on in.

Text Editor Based Keyboard Shortcuts

One thing I'll note before jumping into each shortcut is that these are Mac specific. If you are running on a different system just hop on your favorite search engine and look up what your equivalent is!

Undo

This is a need-to-know, especially for me who incorrectly types very often! If you ever need to undo any of the changes you've made to your code editor simply type command + Z.

Undo Your Undo

Wait! What if you accidentally got trigger happy and undid something you didn't mean to! Don't fret, command + shift + Z is here to save the day!

Wonder Woman appearing out of the destruction

Select Matching Instances

This is one of my favorite keyboard shortcuts because I am sometimes indecisive with my variable names and need to change them. Instead of going through and changing each instance where I called the variable, I select one instance of it and use command + D to select each time that variable appears one at a time.

The reason I like using this one over the one I'm covering next is because sometimes the phrase being matched appears within the name of another variable and I may be happy with that variable! No need to change it!

Select ALL Matching Instances

If you feel confident and comfortable to select all instances that match the phrase you've selected at one time, then give command + shift + L a try.

Undoing the Selects

If you've accidentally selected an instance of the phrase that you didn't mean to select, then use command + U to undo it. Note that if you do it after using command + shift + L it will unselect everything, not just one at a time.

Go to Beginning of Line

If you are ever in the middle of a line (or even the end) and want to jump to the beginning of the line use command + left arrow or control + A instead of holding down the left arrow until you reach the start.

Go to End of Line

To get to the end of the line you can either use command + right arrow or control + E.

Select All Code From Current Position to Beginning of Line

Similar to jumping to the beginning of the line, in order to select the code from your cursor's current position to the beginning of the line you should use command + shift + left arrow or control + shift + A.

Select All Code From Current Position to End of Line

You may have already guessed that there is also a shortcut to select code from your cursor's current position to the end of the line! In order to do this use command + shift + right arrow or control + shift + E.

Select All Code

Any time you want to select all the text in one file use command + A.

Select Current Word

So now you may be wondering if there is a shortcut to select the word your cursor is currently near. Well there is! If your cursor is left of the word you want to select use option + shift + right arrow. Now if your cursor is to the right of the word you would use option + shift + left arrow.

You can continue to select more than word if you keep clicking the arrow in the desired direction.

Go to Start / End of a Word

If you want to move around within a line without jumping straight to the beginning or end of the line there is a shortcut that allows you to move one word at a time. This is option + left arrow or option + right arrow, which one you choose is dependent upon which direction you'd like to move in.

Delete Code From Current Position to Beginning of Line

When you have dead code that you no longer need and it requires you to remove everything from your cursor's current position to the beginning of the line you can use option + delete.

Delete Code From Current Position to End of Line

In order to delete the code from your current position to the end of the line use control + K.

General Computer / Browser Keyboard Shortcuts

Quit Current Application

If you want to quit an application, which will close all open windows of said application, use command + Q.

Close Current Window

When you are ready to close the current window you are in (like I will be when I'm finished writing this blog post 😉) you can use command + W.

Minimize Current Window

If you don't want to close the window but want it off the screen, then you should minimize it by using command + M.

Minimize All Windows of an Application

We can go even further by minimizing all windows that belong to a particular application by using the shortcut command + option + M.

Open New Window

In order to open a new window of an application use the shortcut command + N

Open New Tab

If you ever want to open a new tab while you are in your browser use command + T.

Open Last Closed Tab

When you accidentally close a tab you didn't mean to close, you can use command + shift + T to get it back!

Disney character saying "witchcraft"

Switch Between Tabs

Switching between tabs while in the browser has to be one of my favorite keyboard shortcuts because when I write blogs I often reference many articles. To go towards the left use command + shift + ] and to go to the right use command + shift + [.

Select Address Bar to Search

This is one of my favorite finds during my research for this blog! While in the browser you can use command + L to select the address bar so you can start typing in your next web destination!

Invoke Spotlight

Another general useful shortcut is command + space to invoke spotlight to search your machine.

Open Application Switcher

If you are ever working across multiple applications and need to switch frequently use command + tab. You keep pressing tab until you reach the application you want as your current window.

Open Current Application's Preferences

Another awesome find of my research!!

little girl REALLY excited about eating cotton candy

In any application use command + , to open up the applications preferences.

Other Shortcuts Introduced in Discussion Thread

Copy

I have no idea how I managed to forget to include this one as well as the next two since I use them probably the most on a daily basis. Thanks to That Blair Guy for reminding me of them in the discussion.

Anyways, to copy any selected code in a browser, text editor, etc. use command + C.

Paste

Whenever you want to paste code use command + P

Cut

To cut selected code use command + X

Search in File

Anna Simoroshka reminded me of this other amazing shortcut to search for something in a file. To do this use command + F.

Search in Whole Project

She also taught me that command + shift + F will search all files within a project in a text editor. This is a new tool I'll be using frequently.

Search File by Name

Another new one that Anna taught me is command + P within a text editor to search for a file by name.

Final Thoughts

This was a fun blog post for me to research and write. I learned so many new shortcuts I never knew of and I even thought of a few I use very often while writing it.

If you are new and are thinking "Holy cow! How do I remember all these?" don't worry. I also felt overwhelmed when I first started. Like anything, with more repetition and practice it'll become secondhand nature to use them.

Thanks for reading and happy coding!

Note: The cover image for this post is brought to you from the Ballycotton Cliff Walk in Ballycotton, Ireland.

Sources

⚡️ Mac Keyboard Shortcuts for Web Developers
24 keyboard shortcuts Mac users need to know

Discussion (12)

Collapse
thatblairguy profile image
That Blair Guy

Congratulations on discovering keyboard shortcuts, they are a superpower.

Three bonus items for you:

  • Command + C - Copy (depending on the program and whether anything is highlighted, this will copy the highlighted text, the current line, or even an image. Use this in the Finder to copy files.
  • Command + X - Cut. Similar to Copy, except that it removes the item from the source location.
  • Command + V - Paste. Places the copied/cut item at the current point of focus.
Collapse
torianne02 profile image
Victoria Crawford Author

How did I manage to forget the ones I use THE MOST 🤦🏼‍♀️ 😂

Thank you for adding them!

Collapse
gypsydave5 profile image
David Wickes • Edited

Fantastic list - I didn't know a lot of these.

Something I accidentally discovered is that most of the Emacs-style shortcuts will also work on OSX - you may need an alternative keyboard to access the Meta (aka Alt) key, but here are some basics using Control:

  • Control-e: end of the line
  • Control-a: beginning of the line
  • Control-k: 'kill' (cut) everything from the cursor up to the end of the line
  • Control-y: 'yank' (paste) what you just killed
  • Control-h: delete a character backwards
  • Control-d: delete a character forwards
  • Control-n: next line
  • Control-p: previous line
  • Control-f: forward one character
  • Control-b: backwards one character

There are many more. To make the most of these swap your CapsLock key with Control (can be done in the Settings -> Keyboard -> Modifier keys...).

Have fun.

Collapse
renzit profile image
Renzo Mayer

Well done and thank you!
I think is a nice iteration on shortcuts, for te next one, if there is one, I would love to hear about gestures for the trackpad, switch desktops, etc focused on web operarions workflow!

Collapse
codenutt profile image
Jared

If you reeaaaally like keyboard shortcuts, you should check out Vim.

Collapse
yevgalis profile image
yevgalis

I was looking for this one command + shift + L for a long time, so thank you!

Collapse
simoroshka profile image
Anna Simoroshka

my favorites are cmd + f, and in code editor: cmd + shift + f (search whole project) and cmd + p (search file by name).

Collapse
torianne02 profile image
Victoria Crawford Author

I had no idea about command + shift + F or command + P before! Thank you for sharing.

Collapse
flexdinesh profile image
Dinesh Pandiyan

Thanks Victoria. This is very helpful.

Collapse
pris_stratton profile image
pris stratton

Wow there are loads I didn’t know. Thank you 😁

Collapse
mensdarko profile image
Darko Mens

Good to share

Forem Open with the Forem app