Ask HN: The most useful Mac keyboard shortcuts?
Edit: "Not a shortcut exactly..." tips are most welcome too.
Edit: "Not a shortcut exactly..." tips are most welcome too.
Then command-e, command-g (find next) will search for the selected text without sacrificing the copy/paste clipboard.
Also, the find clipboard is shared between apps, so you can command-e in Safari, then command-g in Xcode.
Works fine on Firefox. I'd say breaking it is a Chrome thing.
And Karabiner Elements (https://github.com/tekezo/Karabiner-Elements) to remap keys to something more useful (who uses Caps Lock anymore?)
It's really nice to use k for "(" and l for ")". I don't have to reach up two rows.
It looks like someone else is currently working on a Swift rewrite. https://github.com/rxhanson/Rectangle
> Spectacle used it's own keyboard shortcut recorder, while Rectangle uses MASShortcut [1], a well maintained open source library for shortcut recording in macOS apps. This cuts down dramatically on the number of bugs that were only in Spectacle because of the custom shortcut recorder.
Not exactly a shortcut, but I once made a gesture-driven shortcut app (https://thimblemac.com) - it’s been on hiatus the past couple years but have been wondering if there’s value in it for programming work contexts.
Did you remap that key combo?
So much easier in terminal and for using shortcuts like ctrl-A & ctrl-E for beginning and end of line, etc.
I use it for both Caps Lock -> Escape/Control and Return -> Return/Control and it's indispensible.
FWIW, Ctrl-[ emits the ASCII code for ESC. So you can save that 'vim pinky' and have the remainder of control codes available to you as well :-).
On Linux you can get it to do the same thing with a combination of xmodmap, setxkbmap and xcape (but it's fiddly) and on Windows with AutoHotkey (but it's fiddly) — neither are as easy to use as Karabiner Elements, but they do work.
It's better to use a full size keyboard and use two hands for keyboard combos, e.g. for Ctrl+A use right Ctrl, for Ctrl+N use left Ctrl, for Ctrl+E use right control. Takes a little while to master but it puts much less pressure on your fingers.
Mapping Caps to Esc is a good choice though.
Control-cmd-F makes most apps full screen (or toggles back)
^k, ^y, etc...standard text widgets accept basic Emacs commands.
cntrl+p: go up one line
cntrl+n: go down one line
cntrl+k: cut line proceeding cursor
cntrl+f: forward one char
cntrl+b: back one char
These work everywhere you can type text on Mac: including in this HN text box, in the url bar, etc. I absolutely love these shortcuts...
aka Emacs keybinds.
> These work everywhere you can type text on Mac
Supposedly they even work on iOS if you plug in a keyboard, which is pretty unexpected if you think about it.
I own a similar app called Witch[1] from Many Tricks (the guy behind Moom). Also a nice Cmd+Tab upgrade.
cmd-shift-A opens Applications folder
cmd-shift-U opens Utilities folder
cmd-shift-L opens ~/Library (might not work on older versions or if ~/Library is invisible)
cmd-shift-H opens Home folder
cmd-shift-C opens toplevel computer folder
cmd-[ "Back" button for Finder windows
cmd-] "Forward" button for Finder windows
cmd-1 changes window to icon view
cmd-2 changes window to list view
cmd-3 changes window to column view
cmd-4 changes window to cover flow view
(seriously) Cmd Shift 4 also has AFTERTOUCH - so do the command, draw out the grey capture window, and keep holding the mouse button WHILE trying using different combinations of Ctrl, Option, and Shift. Allows you to resize your capture window.
Without the initial SHIFT dumps the file to the Desktop. With the SHIFT adds the screenshot to your clipboard.
Shift-Cmd-3 will simultaneously capture a screenshot of ALL monitors connected to your system and put the files on the Desktop.
Shift-Cmd-4 will give you a cursor with which you can draw a rectangle of the area desired; if you then hit Space, however, the cursor changes to a camera icon which then allows you to click on any open window. That window will then be captured.
Shift-Cmd-5 pulls up a full set of screen capture controls with various options.
I map it cmd-shift-v and I can bounce between all of my most recent clipboards. Saves so much time.
Alfred supports images, rich text and a few other mime types for its history.
"Go to the folder:"
My control key is a. My command key is e. I open apps by pressing w + <key>. ie w+l opens VSCode. Press it again and it switches to previous app (under the hood w+l calls a Keyboard Maestro macro).
It’s quite awesome.
Brings up the Help Viewer where you can search any menu items for the current app.
This IS pretty much the built-in command palette for all apps!
* command+O: open file
* command+shift+3/4/5: screenshot tool (one of the best shortcut on macOS in my opinion)
* command+alt+space: switch keyboard input source
* "=", ">", "<" "-", while holding down `option` gives you "≠", "≥", "≤", "–"
Apps:
+ Safari: command+shit+\ (show tab overview)
+ FileMerge: command+D to jump to next conflict
+ VSCode: control+shift+E: toggle focus
+ iTerm2: command+] to switch between panes
+ iTerm2: command+K: clear buffer
+ Dash: command+shift+D
+ Spectacle: https://github.com/eczarny/spectacle#keyboard-shortcuts. And also, as zuccs's comment https://news.ycombinator.com/item?id=20621517
Cmd-tab for switching between apps quickly. Takes a few days to get really good with it.
Key commands generated to follow any link on the page. It makes browsing really efficient.
Probably the most important knowledge is to learn the Mac modifier key symbols, since they'll help you learn more shortcuts from the menu items you use.
⌃ Control ⇧ Shift ⌥ Option ⌘ Command
——— SCREENSHOTS ———
[⌃⇧⌘4] Copy screen selection to clipboard. In this mode:
- Press [space] to capture a single window.
- Hold [⌥] to toggle whether to include window shadow.
[⇧⌘5] Show extra options, including screen record (10.14+)
——— MISSION CONTROL ———
[⌘MissionControl] Show desktop
[⌘Tab] Switch between apps. In this mode:
- Press Tab to go highlight the next app.
- Press [⇧Tab] or [`] to highlight the previous app.
- Press [Q] to quit the highlighted app.
- Press [H] to un/hide the highlighted app.
[⌘`] Switch between windows of the current app
——— TEXT EDITING ———
[⌥Delete] Delete word
[⌥⇠]/[⌥⇢] Move cursor to next word
[⌥⇡]/[⌥⇣] Move cursor to next paragraph
[⌘⇠]/[⌘⇢] Move cursor to start/end of line
[⌘⇡]/[⌘⇣] Move cursor to start/end of text field
——— FINDER ———
[⌘Delete] Move to trash
[Enter] Rename selected file
[⌥⌘V] Move copied file here
- You can see this option if you open the Edit menu and hold down [⌥].
——— DRAGGING ———
- You can drag the "document proxy" icon in any titlebar. Make sure to hold the icon for a bit before dragging. (This delay is probably to prevent people who want to move the window from dragging the icon.)
- If you're dragging a file into a folder, press [Space] to immediately open the "spring-loaded" folder.
- In many apps, hold down [⌥] to duplicate instead of move.
- In Finder, dragging a file across filesystems will duplicate by default. Hold down [⌘] to move instead.
- You can [⌘Tab]/[⌘`] while you're dragging an item.
- To navigate a open/save dialog to a particular place, drag the folder or file into the edges of the dialog. Be careful not to drag it into the middle white area of the dialog, as in some cases it might move/copy the file.
- To open a Finder window at the same location as an open/save dialog, use [⌘R] (R for "reveal").
———
(Note: There are many more shortcuts in each category. These are just the ones that I find the most useful.)
Suggests your experience with Apple computers dates back at least to the '80s! :-D
shift+cmd+delete = empties trash bin.
It's easily my goto combo to delete something fast.
Lock screen
Locks your screen