News for hackers. Stuff that matters.
Re:Keyboard tricks from a macOS app dev by aaronbrethorst on Sunday April 23, 2023 @05:46PM (#35680975)
I was hoping this was about lesser known macOS keyboard shortcuts. Alas.

Apple has a pretty exhaustive list of so-called document shortcuts that I find particularly useful: https://support.apple.com/en-us/HT201236#text

Ctrl+A and Ctrl+E in particular to jump to the beginning and end of a line are a pair that I use dozens of times per day.

Same with Opt+Delete to delete the previous word.

I use Opt+Left Arrow and Opt+Right Arrow to move the cursor back and forward by whole words so often that I didn't even think about including it in here until I unconsciously used it while editing text.

Also:

Cmd+Space brings up Spotlight and is a great way to launch apps and open documents.

I've used SizeUp for well over a decade to rearrange my Mac's open windows. It's literally the first app I install when I get a new computer. https://www.irradiatedsoftware.com/sizeup/

Re:Keyboard tricks from a macOS app dev by dan-robertson on Sunday April 23, 2023 @06:03PM (#35681124)
Lots of those shortcuts are basically Emacs shortcuts. I’m always sad using gdocs on Linux that they don’t support the Emacs shortcuts.
Re:Keyboard tricks from a macOS app dev by colechristensen on Sunday April 23, 2023 @06:30PM (#35681331)
Not just Emacs, but anything that uses readline or similar libraries. Most shells for example.

https://en.wikipedia.org/wiki/GNU_Readline

https://github.com/chzyer/readline/blob/master/doc/shortcut....

Re:Keyboard tricks from a macOS app dev by dan-robertson on Monday April 24, 2023 @06:05AM (#35685592)
I mean, readline shortcuts are also based on Emacs ones.
Re:Keyboard tricks from a macOS app dev by ornornor on Monday April 24, 2023 @06:13AM (#35685633)
Always assumed it was the other way around without any particular evidence.
Re:Keyboard tricks from a macOS app dev by aaronbrethorst on Sunday April 23, 2023 @07:56PM (#35682003)
Yep. Yank and Kill work too, among others
Re:Keyboard tricks from a macOS app dev by interpol_p on Sunday April 23, 2023 @09:34PM (#35682708)
Side note that these Emacs shortcuts also work on iOS pretty much everywhere (you even get it for free in completely custom text renderers, so long as you adopt the UITextInput protocol)
Re:Keyboard tricks from a macOS app dev by ngai_aku on Sunday April 23, 2023 @11:03PM (#35683222)
How are you using the modifier keys in iOS?
Re:Keyboard tricks from a macOS app dev by crazygringo on Monday April 24, 2023 @12:58AM (#35683821)
Just connect a Bluetooth keyboard.

Sometimes I use an iPad plus Bluetooth keyboard for writing.

What's annoying is that keyboard shortcuts mostly work in apps, but are sometimes buggy, because I think they're so rarely tested.

Re:Keyboard tricks from a macOS app dev by eviks on Sunday April 23, 2023 @11:41PM (#35683421)
It's much better to rebind all of those to more ergonomic alternatives that match your other apps using the tools listed (eg, to similar cursor keys you use in a text editor), which is also useful for non Macs you use (where you could do the same rebunds), rather then learning yet another set of bad old combos
Re:Keyboard tricks from a macOS app dev by drbaba on Monday April 24, 2023 @12:27AM (#35683650)
The defaults can be changed (DefaultKeyBindings.dict). However, those keybindings are not just “yet another set of bad old combos”; the same keybindings are used by default in Emacs on any platform, and by most POSIX shells and interpreters (Bash, Zsh, Fish, IPython, etc.). On Mac, they’re inherited by most other GUI text editors (e.g. Sublime).
Re:Keyboard tricks from a macOS app dev by jurip on Monday April 24, 2023 @01:49AM (#35684090)
Yeah. Those are the key combos for editing text, especially on a Mac. If an app does not support them, it's going to be some weird cross platform monstrosity and you're better off if you find a competitor.
Re:Keyboard tricks from a macOS app dev by eviks on Monday April 24, 2023 @03:42AM (#35684738)
These are exactly another set of bad old combos, and the fact that their use is widespread is just another example of how bad very common things are:

  -  it doesn't make sense to have a/e as beginning/end, there is a symmetry in the commands, but there is no symmetry in the a/e keybindings, they are on different rows

  - likewise, it doesn't make sense to use the less convenient ⌃ for such a frequent command (and this is also the rightful criticism of all the bad Emacs pinky defaults)
For example, you could use right ⌘ (a thumb key) as your text movement key (or even Space), then you have home keys

  - JKL; for cursor movements and

  - DF for your word movements (instead of having to move your whole hand to ⌥◀/▶)

  - A/⇧A for line start/end movements or maybe A/G if it's frequent enough to not warrant using ⇧
And then that would match your text editor keybinds, so you don't have to waste time remembering platform-specific keys.

And re. those other apps - it's better to rebind them all (or, rather, use a tool to have the keybinds work in all of them) as well to use something good rather that stick with the bad just because someone lacked good design chops in the past

Re:Keyboard tricks from a macOS app dev by ogsuspect on Monday April 24, 2023 @05:20PM (#35693428)
Thats because they come from GNU Readline
Re:Keyboard tricks from a macOS app dev by drbaba on Tuesday April 25, 2023 @01:48AM (#35696929)
I agree, Readline is the reason they got so widespread. But note that except Bash, none of the shells and interpreters I listed actually use GNU Readline these days — and that Emacs and its keybindings predates Readline.
Re:Keyboard tricks from a macOS app dev by koinedad on Monday April 24, 2023 @01:38AM (#35684015)
I love these built in shortcuts. I’ve added Karabiner to remap caps lock to esc and ctrl (not for Vim) and also right cmd-hjkl for instant arrow key access.

Spotlight usually works for most of my needs as well.

It’s frustrating when an app overwrites built in shortcuts like in Intellij on Mac, searching for shortcuts in the menu bar search doesn’t allow opt-delete if I remember correctly.

Speaking of menu bar search… one of my favorite commands is opt-shift-/ to search available commands in the menu bar of an app.

Re:Keyboard tricks from a macOS app dev by dzhiurgis on Tuesday April 25, 2023 @08:23AM (#35699477)
IntelliJ text expansion hotkeys (option + up/down) or spell checker (option enter) should be part of every operating system.
Re:Keyboard tricks from a macOS app dev by kmarc on Monday April 24, 2023 @01:44AM (#35684052)
I find it fascinating that your examples are actually the readline/emacs shortcuts, or the workarounds that had to be implemented for the lack of PC keys (Home/End/PgUp/PgDown)

The more I got familiar with MacOS, the more I realized all those feature pictures ople praise MacOS for are just workarounds / copies from other systems, and (even power-) users just aren't familiar with other systems hence their amaze.

The inconsistencies that come with intermixing ctrl-option-command are just mind blowing. Even Windows got this right by making the Windows key control window manager specific actions.

Re:Keyboard tricks from a macOS app dev by kitsunesoba on Monday April 24, 2023 @02:03AM (#35684174)
It all depends on where one got their start in computing. I started on a Mac in 1996, and though the keyboard that it came with had home/end/etc I never learned to use them because I didn’t do much that was keyboard intensive, with most of my computer usage being drawing/graphics, games, or web browsing.

By the time I’d started working as a dev fulltime where those keys might’ve been useful, laptops had taken over and my work machine was a MacBook Air which wasn’t large enough to fit those keys even if they’d wanted to, and so I learned the built in macOS text nav shortcuts. They were never a workaround for me because I’d never used the home/end/etc cluster in the first place.

Even today when using Windows or Linux it’s with a 60/65% keyboard without those keys because that’s what’s comfortable. Reaching over to hit home/end on a larger keyboard would feel odd with how far removed it is from the rest of the board.

Re:Keyboard tricks from a macOS app dev by aequitas on Monday April 24, 2023 @06:47AM (#35685895)
> or the workarounds that had to be implemented for the lack of PC keys (Home/End/PgUp/PgDown)

Those keys are not lacking, but on laptop keyboards they are hidden behind the fn+arrow keys. But they also are not workarounds or replacements for those keys. On macOS Home and End scroll the document to the beginning or end, not the cursor to the beginning or end of the line. That can be done with cmd-arrow.

Re:Keyboard tricks from a macOS app dev by snowe2010 on Tuesday April 25, 2023 @09:53PM (#35708922)
I always hated the home/end keys. The way Mac does it is way better and I didn’t really start using Macs until two decades after I used windows and Linux. Cmd+left/right is way easier to use, especially on a laptop and custom keyboard.
Re:Keyboard tricks from a macOS app dev by rstevens333 on Tuesday April 25, 2023 @07:14PM (#35707972)
sizeup is excellent. add swish and it's even better.