Live data from Hacker News

Quick tip for developers who use OS X

news.ycombinator.com

21–30 of 406 posts

Re: Quick tip for developers who use OS X

#21

Earlier quoted context omitted.

A lot of the Emacs shortcuts work in OS X (most of the system) as well as on Linux (bash and other users of readline).

I use Vim and was unaware that this shortcut existed. Are there any other Emacs shortcuts which are useful in OSX?

If you do "set -o vi" you can also use vi shortcuts, such as ESC-j,k to go up/down the history, 0 to go to the beginning of the line, etc.

Re: Quick tip for developers who use OS X

#23
Osx terminal uses almost all of the emacs movement keys by default. Ctrl-a and ctrl-e are useful but I find the meta movement keys to be the most helpful. (usually alt or ESC)

Meta-f jump forward a word

Meta-b jump backwards a word

Re: Quick tip for developers who use OS X

#25
post #23

Osx terminal uses almost all of the emacs movement keys by default. Ctrl-a and ctrl-e are useful but I find the meta movement keys to be the most helpful. (usually alt or ESC) Meta-f jump forward a word Meta-b jump backwards a word

I'm not sure what you're suggesting here.

It's up to the process running in Terminal.app to support the key sequences sent to it. I doubt that M-f would work if your shell (bash, zsh, etc) were in Vi-mode rather than the default of Emacs-mode.

Re: Quick tip for developers who use OS X

#26

Two more tips: * Ctrl-a to go to beginning of line * Ctrl-e to go to end of line

A lot of the Emacs shortcuts work in OS X (most of the system) as well as on Linux (bash and other users of readline).

The basic Emacs key-bindings should work in all Cocoa apps. For instance, the URL bar of your web browser, while text editing in just about any editor (maybe even in Office, but I have not tired in a while), etc. Basically, anywhere you have a cursor, the basic line-editing key bindings should work.

So, in practical terms, this means you have 1 + n clipboards[1]. The main global GUI clipboard (using the command key), and then an app-specific clipboard (using the control key with Emacs bindings). As a developer, it is extremely helpful to have two clipboards in TextMate, for instance.

[1] Technically, the clipboard in OS X maintains a history (not sure what the limit is), but the OS X GUI only exposes the last cut/copied item.

Re: Quick tip for developers who use OS X

#28
Useful when copy/pasting things to share with other people in email and such:

    $ pbpaste | pbcopy
takes the current contents of the copy/paste buffer and removes color/font/background color rich formatting and puts just plain text back into the paste buffer.

And of course pbcopy and pbpaste are also very useful on their own.

Re: Quick tip for developers who use OS X

#29

OK, so for vim users with zsh: bindkey -v Now be happy, hit and, use ^ and $ but also f t and also ,;. You can copy/paste with dd, Y, etc...

set -o vi does the trick for vim. Most vi commands work, but when you type v this will open vi to edit your command line, in case you feel any command is missing.

Re: Quick tip for developers who use OS X

#30
post #23

Osx terminal uses almost all of the emacs movement keys by default. Ctrl-a and ctrl-e are useful but I find the meta movement keys to be the most helpful. (usually alt or ESC) Meta-f jump forward a word Meta-b jump backwards a word

It's not emacs, it's GNU Readline (or likely some BSD readline given apple and the GPL) http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html.

The shortcuts also work in every text field in the OS.

Post reply on HN