Skip to content

Instantly share code, notes, and snippets.

@tannerhodges
Last active October 18, 2022 16:55
Show Gist options
  • Save tannerhodges/9ad999e39007ad4921569975f416734f to your computer and use it in GitHub Desktop.
Save tannerhodges/9ad999e39007ad4921569975f416734f to your computer and use it in GitHub Desktop.
Mac Shortcuts @ Red Ventures 2019-08-21

💻 Mac Shortcuts

tl;dr Use your keyboard. Avoid the mouse.

 

How do we get faster?

  • Typing
  • Traversing
  • Tooling

Bonus: Remove distractions. Clear your screen.

 


 

👨‍💻 Typing

When it comes down to it, you’re only as fast as you can type. Gain a solid foundation with regular practice, then build on that with more powerful settings.

 

Practice, Practice, Practice

Let’s race!

Try keybr.com (or search for others).

 

Make It Faster

System Preferences > Keyboard > Keyboard

  • Key Repeat: Fast
  • Delay Until Repeat: Short

 

Keyboard Shortcuts

System Preferences > Keyboard > Shortcuts

  • Turn off any that annoy you.
    • Launchpad & Dock > Turn Dock Hiding On/Off
    • Input Sources > Select the previous input source
  • Use App Shortcuts for apps without shortcut settings.
    • Safari.app > Enter Responsive Design Mode > ⇧⌘E
    • Safari.app > Exit Responsive Design Mode > ⇧⌘E
    • Sketch.app > Resize to Fit Content > ⇧⌘F
    • Preview.app > Adjust Size... > ⇧⌘I

 

⭐ Document Shortcuts

  • ⌘Arrow Move cursor to beginning/end of document/line.
  • ⌥Arrow Move cursor to beginning/end of previous/next word.
  • ⇧⌘Arrow Select text between cursor and beginning/end of document/line.
  • ⇧Arrow Extend selection to nearest character on previous/current/next line.
  • ⌥⇧Arrow Extend selection to beginning/end of previous/current/next word/paragraph.

For more global shortcuts, read Apple: Mac keyboard shortcuts.

P.S. ⌃⌘Space for emojis, or use an app like Rocket.

 

Aside: Screenshots & Screencasts

  • ⇧⌘3 to capture the whole screen.
  • ⇧⌘4 + click/drag to capture a portion of the screen.
  • ⇧⌘4 + Space to capture windows.
  • ⇧⌘5 to see options for screen recordings.

For more screenshot shortcuts, see Apple: How to take a screenshot on your Mac.

 

Aside: Keep Your Mac Awake

Keep your Mac awake with an app to save time logging back in when your Mac falls asleep (or to help keep your screen on during a presentation).

 


 

🤹‍ Traversing

Besides raw typing speed, your ability to jump between applications and traverse your project is make or break. It’s all about how quickly you can find things.

 

Window Management

🚫 Avoid ✅ Use
Dock Icons Spotlight (⌘Space) or Alfred
Mission Control ⌘Tab for Apps, ⌘` for Windows
Clicking Tabs ⌘] and ⌘[
Resizing Windows Moom, Magnet, or Spectacle
  • Instead of clicking on Dock icons, use ⌘Space Spotlight (or a tool like Alfred) to open apps.
  • Instead of Mission Control, use ⌘Tab to cycle through apps and ⌘` to cycle through windows.
  • Instead of clicking on tabs, use ⌘] and ⌘[ to cycle through tabs (works in browsers, editors, even Finder).
  • Instead of manually resizing windows, use a tool to scale and position them for you.

 

Searching Folders

Finder > Preferences > Advanced

  • When performing a search: Search the Current Folder

 

Changing Directories

Fuzzy match your frequent directories (instead of manually typing or tabbing out the whole path). https://github.com/rupa/z

brew install z

Then add it to your .bash_profile:

# z (Faster cd)
# https://github.com/rupa/z
. /usr/local/etc/profile.d/z.sh

P.S. Use VS Code workspaces!

 

Text Editor Shortcuts

🔥 Combine these with Document Shortcuts for ludicrous speed.

Note: These shortcuts are based on VS Code’s default settings, but can also be applied to other editors.

Preferences: Open Default Keyboard Shortcuts (JSON)

Key Command Command ID
⌘P Quick Open workbench.action.quickOpen
⇧⌘P Show All Commands workbench.action.showCommands
⌘D Add Selection To Next Find Match editor.action.addSelectionToNextFindMatch
⇧⌘L Select all occurrences of current selection editor.action.selectHighlights
⇧⌥I Insert cursor at end of each line selected editor.action.insertCursorAtEndOfEachLineSelected
⌥↓ Move Line Down editor.action.moveLinesDownAction
⌥↑ Move Line Up editor.action.moveLinesUpAction
⌘Enter Insert Line Below editor.action.insertLineAfter
⇧⌥↓ Copy Line Down editor.action.copyLinesDownAction
⇧⌘\ Jump to matching bracket editor.action.jumpToBracket
⌘/ Toggle Line Comment editor.action.commentLine
⇧⌘] Next Editor workbench.action.nextEditor
⇧⌘[ Previous Editor workbench.action.previousEditor
⌘F Find actions.find
⇧⌘O Go to Symbol... workbench.action.gotoSymbol
⌘K M Change Language Mode workbench.action.editor.changeLanguageMode
⇧⌥F Format Document editor.action.formatDocument
⌘B Toggle Sidebar Visibility workbench.action.toggleSidebarVisibility
⌥z Toggle Word Wrap editor.action.toggleWordWrap

Other Useful Shortcuts

  • Basic Editing
    • Fold Region (⌥⌘[)
  • Editor/Window Management
    • Move Editor (⌘K ⇧⌘→)
    • Move Editor into Next Group (⌃⌘→)
    • Open Editor at Index (⌃1, ⌃2, etc.)
  • File Management
    • Close Others (⌥⌘T)
    • Reopen Closed Editor (⇧⌘T)
  • Display
    • Open Preview to the Side (⌘K V)
    • Toggle Integrated Terminal (⌃`)

Custom Shortcuts

~/Library/Application Support/Code/User/keybindings.json

  • Transpose
    • editor.action.transpose
  • Case Conversion
    • editor.action.transformToLowercase
    • editor.action.transformToTitlecase
    • editor.action.transformToUppercase
  • Reset Zoom
    • workbench.action.zoomReset

Example keybindings.json:

[
    // Open JSON Settings
    { "key": "cmd+,",        "command": "workbench.action.openSettingsJson" },
    { "key": "shift+cmd+,",  "command": "workbench.action.openSettings" },

    // Reset Zoom
    { "key": "cmd+0",        "command": "workbench.action.zoomReset" },

    // Focus Tabs
    { "key": "cmd+1",        "command": "workbench.action.openEditorAtIndex1" },
    { "key": "cmd+2",        "command": "workbench.action.openEditorAtIndex2" },
    { "key": "cmd+3",        "command": "workbench.action.openEditorAtIndex3" },
    { "key": "cmd+4",        "command": "workbench.action.openEditorAtIndex4" },
    { "key": "cmd+5",        "command": "workbench.action.openEditorAtIndex5" },
    { "key": "cmd+6",        "command": "workbench.action.openEditorAtIndex6" },
    { "key": "cmd+7",        "command": "workbench.action.openEditorAtIndex7" },
    { "key": "cmd+8",        "command": "workbench.action.openEditorAtIndex8" },
    { "key": "cmd+9",        "command": "workbench.action.openEditorAtIndex9" },

    // Emmet - Balance (aka "Match Pair")
    // https: //docs.emmet.io/actions/match-pair/
    { "key": "ctrl+d",       "command": "editor.emmet.action.balanceOut" },
    { "key": "ctrl+j",       "command": "editor.emmet.action.balanceIn" },

    // Select Inside Brackets
    { "key": "ctrl+shift+m", "command": "-editor.action.toggleTabFocusMode" },
    { "key": "ctrl+shift+m", "command": "editor.action.selectToBracket" }
]

For more details on VS Code shortcuts, see VS Code: Key Bindings.

 


 

👷 Tooling

From here on out, it’s all about automation. What tools can help you avoid repeating yourself?

 

Text Editor Snippets

Preferences > User Snippets > New Global Snippets file...

~/Library/Application Support/Code/User/snippets/global.code-snippets

{
    /**
     * Placeholder Images
     */
    "placehold.it": {
        "scope": "",
        "prefix": "placehold",
        "body": [
            "<img src=\"https://placehold.it/${1:300}x${2:300}\" alt=\"$3\">"
        ],
        "description": "Add placeholder image"
    }
}

Enable tab completion!

~/Library/Application Support/Code/User/keybindings.json

{
    "editor.tabCompletion": "on"
}

For more details on how to create custom snippets, see VS Code: Snippets.

P.S. If you purchase the Powerpack, Alfred Snippets enable you to reuse global snippets everywhere.

 

Text Editor Plugins

Linting and formatting tools:

For more details on RV’s standard formatting tools, see FE Standards: Linting and Formatting.

 

Bash/ZSH Aliases

Add aliases to your .bash_profile.

# ------------------------------
# Git
# ------------------------------

alias gs="git status"
alias ga="git add -p"
alias gaa="git add --all"
alias gc="git commit"
alias gca="git commit --amend"
alias gd="git diff"
alias gdc="git diff --cached"
alias gm="git merge"
alias gk="git checkout"
alias gp="git push"
alias gpf="git push --force-with-lease"
alias gl="git pull"
alias gb="git branch"
alias gr="git reset HEAD"

For more details on Bash, see Flavio Copes: The Bash shell and Devhints: Bash scripting cheatsheet

 

Clipboard History

🔥 But for real, once you get clipboard history you’ll wonder how you ever lived without it.

 

Offline Documentation

 

The list goes on…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment