Mac Shortcuts

Oct 30, 2023

Please refer to this post if you are a Windows user.

In this post, I will be sharing why and how I ditched the mouse and started utilising keyboard shortcuts.

Why avoid the mouse?

As a software engineer, efficiency is of the essence, especially when one is dealing with many tasks in his bucket or meeting tight deadlines. For any typing setup, majority of the time is spent moving between the keyboard and mouse. Fortunately for us, we can save this precious time by mastering keyboard shortcuts that can perform the same functions/tasks. Not only do you become more productive, you also get to look really cool (somewhat) and experience what it is like to feel like an experienced hacker (sortof).

It will require some practice to master and apply them properly. But rest assured, once you overcome this steep learning curve, you will witness your productivity drastically increase overtime. Below is a compilation of shortcuts that I have learnt and frequently use on Web browsers, Terminals and VSCode.

Glossary of Shortcuts

Basic

 Command + A                             Select all                                                          
 Command + C                             Copy                                                                
 Command + F                             Find keyword                                                        
 Command + Option + F                    Replace keyword                                                     
 Command + Q                             Close application                                                   
 Command + S                             Save                                                                
 Command + V                             Paste                                                               
 Command + W                             Close active window                                                 
 Command + X                             Cut                                                                 
 Command + Z                             Undo                                                                
 Command + `                             Toggle between application windows                                  
 Command + Shift + Z                     Redo                                                                
 Command + Ctrl + F                      Fullscreen                                                          
 Command + Up/Down                       Move cursor to start/end of document                                
 Command + Left/Right                    Move cursor to start/end of line                                    
 Command + Option + D                    Show Dock                                                           
 Command + Option + Space                Open Finder                                                         
 Command + Mission Control               Show/Hide opened apps                                               
 Command + Shift + 3                     Print full screen                                                   
 Command + Shift + 4                     Select area and print screen of selected area                       
 Command + Shift + 5                     Screen recording                                                    
 Command + Shift + Up/Down               Select all characters from cursor to the top/bottom of the document 
 Command + Shift + Left/Right            Select all characters left/right of the cursor                      
 Command + Space + 'Type your search'    System search                                                       
 Command + Tab                           Toggle applications                                                 
 Ctrl + Up                               View all applications from desktop                                  
 Shift + Up/Down                         Select characters above/below the line                              
 Shift + Left/Right                      Select characters left/right of the cursor                          
 Option + Up/Down                        Move current line above/below it                                    
 Option + Left/Right                     Move cursor to the start/end of words                               

Browser

 Comamnd + D                                     Bookmark current tab                      
 Command + L                                     Move cursor to address bar                
 Command + R                                     Reload page                               
 Command + T                                     Open new tab                              
 Command + W                                     Close active tab                          
 Command + Shift + T                             Open recently closed tab                  
 Command + Shift + W                             Close all active windows                  
 Command + Left/Right                            Navigate to previous/next page in history 
 Control + Tab OR Command + Option + Left/Right  Toggle between tabs                       
 F12                                             Open web console                          

VSCode

 Command + L                               Select line                                                  
 Command + P                               Search for file                                              
 Command + N                               Work on a new file                                           
 Command + W                               Close active tab                                             
 Command + Shift + F                       Find keyword in directory                                    
 Command + Shift + K                       Delete line                                                  
 Command + Shift + P                       Open command palette                                         
 Command + Shift + V                       Preview Markdown file on the side                            
 Command + Option + Up/Down                Add cursors to multiple lines at the same horizontal positon 
 Command + Option + Left/Right             Toggle tabs                                                  
 Command + \                               Split code editor/Terminal                                   
 Command + /                               Comment line of code                                         
 Ctrl + `                                  Open/close Terminal in code editor                           
 Ctrl + Shift + `                          Open new Terminal in code editor                             
 Option + Shift + Up/Down                  Copy and paste current line above/below it                   
 Option + Shift + Left/Right               Select words to the left/right of the cursor                 
 `Select keyword` + Command + D            Add cursor to all found keywords one at a time               
 `Select keyword` + Command + Shift + L    Add cursor to all found keywords                             

Bash/Terminal

 Command + D                            Split Terminal vertically                                                         
 Command + Shift + D                    Split Terminal horizontally                                                       
 Command + T                            Open new Terminal tab                                                             
 Command + W                            Close active Terminal tab                                                         
 Command + Shift + W                    Close all active Terminal tabs in the same session                                
 Command + Left/Right                   Toggle between Terminal tabs                                                      
 Command + Option + Up/Down/Left/Right  Toggle between split Terminals in the same tab                                    
 Command + Shift + I                    Broadcast input to multiple Terminal tabs in the same session (iTerm) 
 Ctrl + A                               Move cursor to start of line                                                      
 Ctrl + E                               Move cursor to end of line                                                        
 Ctrl + H                               Clear character before cursor position                                            
 Ctrl + D                               Clear character after cursor position                                             
 Ctrl + U                               Clear line before cursor position                                                 
 Ctrl + K                               Clear line after cursor position                                                  
 Ctrl + L OR `clear` OR `cls`           Clear screen                                                                      
 Ctrl + W                               Delete previous word                                                              
 Ctrl + C                               Cancel program                                                                    
 Ctrl + Z                               Stop program                                                                      
 `history`                              Show history of commands                                                          
 Option + Left/Right                    Move cursor between words                                                         
 Up/Down                                Cycle history of commands                                                         

Other ways to shortcut your workflow

  1. Learn to touch-type, which incorporates all your fingers to access the keys on your keyboard optimally. With sufficient practice, you will be able to master typing without glancing on the keys, saving time as a result.

  2. Use Tabs for autocompletion in the Terminal, especially when your folder/file names are long/foreign.

  3. When inputing text in multiple input boxes, use Tabs instead of moving the mouse to proceed to the next input.

  4. Use aliases to execute long/complex commands

    • alias nrs=npm run start (Executes npm run start with nrs)

    • alias gps=git push (Executes git push with gps)

  5. Broadcast input to multiple Terminal tabs in the same session if the same executions need to be done on multiple replica servers (You will need to install iTerm2 for this)

Conclusion

Ever since I started learning and using these shortcuts, it was excruciating to realise the amount of time wasted performing repetitive work (Eg. Editing the same variable names repeatedly; Highlighting a block of text; Deleting characters one by one using Backspace). To anyone who is using a computer, ditch the mouse and give these shortcuts a shot. Afterwards, you can reward yourself with a nice coffee break.

  1. Keyboard shortcuts for a Developer

  2. 10 Essential Keyboard Shortcuts For Programmers

  3. Bash Shortcuts

  4. Windows vs. Mac: 70+ Common and Helpful Keyboard Shortcuts

  5. Visual Studio Code - Keyboard Shortcuts for Mac

  6. iTerm2

  7. Typing Techniques – 5 Skills to Master