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

Add emacs key bindings to Microsoft Word Apps
Emacs users get addicted to the standard key bindings (which are also available in Cocoa apps). Microsoft Word doesn't support these by default, but you can add them through customization. Here are the ones I find most useful:
  • StartOfLine: Control-A
  • EndOfLine: Control-E
  • LineUp: Control-P
  • LineDown: Control-N
  • CharLeft: Control-B
  • CharRight: Control-F
To set these up in Word, go to Tools » Customize » Customize Keyboard. From the Categories panel, choose All commands. Find each of the entries in the above list, select the Press new shortcut key box for each, then type the shortcut as shown above and click Assign. (Word will tell you if any of the shortcuts are currently assigned to other commands.)

The icing on the cake is to get Control-K working. You can do this with a macro. Go to Tools » Macro » Macros. Set the macro name to CtrlK, then click Create. When the macro window appears, add the following lines just before the End Sub line:
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Hit the W icon on the toolbar to save the macro and go back to Word. Now go back to the Tools » Customize » Customize Keyboard window, choose Macros from the Categories pane, and assign your new macro to Control-K.
  • Currently 3.57 / 5
  You rated: 2 / 5 (7 votes cast)

Add emacs key bindings to Microsoft Word | 9 comments | Create New Account
Click here to return to the 'Add emacs key bindings to Microsoft Word' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Opt-b or opt-f? XP saving issues
Authored by: hmelman on Feb 16, '07 10:00:37AM

Works great. There are commands for WordLeft and WordRight but I could not bind them to option-b or option-f. Too bad there's no equivalent in Excel or PowerPoint.

Also I tried this on Word XP. The keyboard customizations are on the Options tab. alt-b and alt-f worked fine but ctrl-p and ctrl-f conflicted with Print and New. However trying to save these changes to the template kept giving me errors that was read only. It wasn't though the Templates folder was. Changing it didn't help and I didn't bother tracking it down.

[ Reply to This | # ]
Add emacs key bindings to Microsoft Word
Authored by: osxpounder on Feb 16, '07 12:17:24PM

Thanks for that short list. I haven't used those shortcuts since 1994 or so and forgot most of 'em.

[ Reply to This | # ]
Add emacs key bindings to Microsoft Word
Authored by: bjelkeman on Feb 17, '07 08:37:44AM

I wonder why I never figured this out myself. I have been missing these in Word for some time now. Thanks.

I thought that adding the command PasteFromScrapbook as Ctrl-Y would give me a yank command to go with the Ctrl-K command, but that did not work.

Now if I only could set a mark and select region as well....

[ Reply to This | # ]
Add emacs key bindings to Microsoft Word
Authored by: beniamino38 on Feb 19, '07 01:14:15AM

You're looking for:

EditPaste: ctrl-Y

Mark-region etc is a little tricker, I think

[ Reply to This | # ]
VBacs - freeware pre-coded macros for same
Authored by: bugmenot on Feb 19, '07 06:08:33PM
VBacs does this as well. I seem to recall having to do something a little exotic to get the Macintosh version of word to accept it as a valid macro file (like copying and pasting the macros into a new document so that it appeared to word to originate from an Apple Word document), but other than that it works great. Makes word slightly less intolerable anyway ;-)

[ Reply to This | # ]
Select line
Authored by: Lutin on Mar 07, '07 12:47:07AM
Great idea.

To have a Textmate Command+Shift+L equivalent (select line), use this macro:

Sub SelectLine()
    Selection.HomeKey Unit:=wdLine
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
End Sub

[ Reply to This | # ]
Add emacs key bindings to Microsoft Word (2008)
Authored by: nomis on Jul 03, '08 12:44:03AM
Since Word 2008 doesn't support VB scripts, the Ctrl+K (delete to end of line) method above doesn't work anymore. Here's a workaround.

The solution is to use Word's "EndOFLineExtend" command, which extends the selection to the end of the line, then delete the selection. Normally, this command has the keyboard shortcut of Shift+End. I'm using that in the Applescript below.

So . . . create an Applescript with this code:

tell application "Microsoft Word"
   execute key binding (find key key code (build key code key1 shift_key key2 end_key))
   delete selection
end tell
...and save it as "Delete to end of line\ck" in your ~/Documents/Microsoft User Data/Word Script Menu Items/ folder. The "\ck" (note that it's a backslash) at the end tells Word to use Ctrl+K for this custom script.

Now you have Ctrl+K back in Word 2008. Enjoy.

[ Reply to This | # ]
Add emacs key bindings to Microsoft Word (2008)
Authored by: ylon on Aug 13, '08 07:44:17AM

But can we also figure out a way to get this into a different copy buffer versus deleting it? Such as scrapbook and then pulling it back out with ctrl-y?

[ Reply to This | # ]
Add emacs key bindings to Microsoft Word (2008)
Authored by: ylon on Aug 13, '08 07:46:58AM

Taking a quick look without implementing anything, it seems that one could put in a CopyToScrapbook somehow prior to the deletion in this script and then just use a PasteFromScrapbook for ctrl-y...

[ Reply to This | # ]