Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use command line editing keys in Cocoa apps Apps
Ok, here's one for all the UNIX geeks!

All Cocoa apps respond to familiar commandline controls. This is what I mean, go into a Cocoa application (Omniweb, TextEdit, anything that is not Carbon or Classic) and click on any text field.

Type some random stuff, then press CTRL-A, it will bring the cursor to the beginning of that line, which is a common control in UNIX command lines. [Note: CTRL = the control key]

Read the rest of the article if you'd like to learn a number of other keyboard shortcuts for text editing in Cocoa apps.

[Editor's note: This isn't really just for UNIX geeks. How many times have you wanted a quick way to navigate around a text box without using the mouse?! Learn a few of these shortcuts, and free yourself from the mouse!]

New things:
  • ctrl-a = brings cursor to the beginning of a line
  • ctrl-d = deletes the letter in FRONT of the cursor
  • ctrl-e = brings cursor to the end of a line
  • ctrl-k = erases an entire line in front of the cursor
  • ctrl-o = acts like return, but cursor stay in the same place
  • ctrl-t = brings the letter that is behind the cursor move forward one, switching places with the next letter.
  • ctrl-v = moves cursor to the end of a document, or line
  • ctrl-w = deletes everything behind the cursor.
  • ctrl-x = WEIRD STUFF, not sure.. maybe a more geeky UNIX person than me can tell us what this is supposed to do. (Very slow response and some weird characters)
  • ctrl-y = yeah...don't know what this does either.
Stuff you can already do with other keys:
  • ctrl-b = left arrow
  • ctrl-f = right arrow
  • ctrl-h = delete
  • ctrl-i = tab
  • ctrl-j = return
  • ctrl-n = down arrow
  • ctrl-p = up arrow
  • Currently 1.86 / 5
  You rated: 1 / 5 (7 votes cast)

Use command line editing keys in Cocoa apps | 2 comments | Create New Account
Click here to return to the 'Use command line editing keys in Cocoa apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
key strokes
Authored by: Anonymous on Mar 31, '01 10:24:38AM
These seem to be that infamous emacs key sequence. For instance, Control-y is 'yank back', meaning pasting a block of characters that is most recently deleted by C-k. BTW, C-k is 'kill'.

Now, an interesting part is that C-y does not paste something deleted by the standard Command-C or -X. So, if you familiarize yourself with the C-k C-y combo, you have two instant pasting boards.

For more info, see emacs help. You can get one as follows:

  1. launch emacs from the command line.
  2. type Control-h and i (just 'i', not C-i)
  3. bring a cursor down to the line starting with '*Emacs'. This brings up a new page.
  4. bring a cursor to the line starting with '*Key Index'
  5. here we are, all the default key sequence is listed
  6. you can leave the help system by typing 'q' in any page
  7. In order to quit emacs, type Control-x, Control-c in this order

[ Reply to This | # ]
key strokes
Authored by: Anonymous on Mar 31, '01 12:57:33PM

Hey thanks for the response. That whole C-k, C-y is pretty cool, now I got another clipboard! Too bad only Cocoa apps can take advantage of it.

[ Reply to This | # ]