I'm looking to be able to select the current word my text cursor is inside on OSX (10.7.3).

For people who have used vim before, I want to be able to do a similar thing to the 'ci_' command, where '_' can be 'w', '(', '[', etc. to specify deleting the word or contents of a parens/bracket and enter insert mode.

The best way I've figured to do this is Option+Left then Shift+Option+Right to first navigate to the left end of the word, then select to its right end. Is there a way I can create a macro to do both of these at once?

2 Answers 2


This has been covered in a screencast on the Ask Different Blog. I encourage you to watch the video, but I'll summarize here.

First, create a little AppleScript that presses the two keyboard shortcuts. Open AppleScript Editor (in /Applications/Utilities) and paste this in:

tell application "System Events"
    key code 123 using option down
    key code 124 using {shift down, option down}
end tell

Save that as a script in ~/Library/Scripts (create the folder if it doesn't already exist).

Now, install the app FastScripts. It's free for up to 10 scripts.
Open the FastScripts preferences, find your Select Word script, and assign a keyboard shortcut to it.

Now you can press your chosen shortcut in any app and the current word will be selected.


Another option would be to create ~/Library/KeyBindings/ and save a property list like this as DefaultKeyBinding.dict:

    "~w" = selectWord:; // option-w

The custom keybindings don't work in some cross-platform applications (or currently Xcode), but they don't have any perceivable delays like AppleScripts or Keyboard Maesto macros.

For more information, see hcs.harvard.edu/~jrus/Site/Cocoa Text System.html, lri.me/keybindings, and brettterpstra.com/tag/keybindings.

  • Unfortunately Xcode is where I'd most prefer to use these bindings. But the delay-free aspect is interesting! Thanks (I'd up vote, but my low rep on this exchange won't allow me)
    – JKomusin
    Mar 20, 2012 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .