Emacs: Xah AutoHotkey Mode, xahk-mode.el

By Xah Lee. Date: . Last updated: .

xahk-mode.el is a emacs major mode for editing AutoHotkey (AHK) scripts.

Get it by Donation

Goto paypal.com, send $32 to Xah@XahLee.org (be sure to include your correct email address. I need that to send it to you.)

Write in message area: xahk-mode.el



autohotkey emacs xahk-mode
xahk-mode, showing its menu.

Comment Uncomment Code

Type Alt+; (“comment-dwim”) to comment or uncomment current line or text selection in a smart way.

Keyword Completion

Press Tab (or Meta+Tab) to complete the word to the left of cursor to one of AHK's keyword. All the language's words are supported.

xahk-mode autocompletion
xahk-mode showing name completion.

💡 TIP: If you are looking for a built-in word that has a name “key” in it, but you don't remember how it starts, you can type Escape Tab on a blank line, then it will list all AHK's buildin words. Then, you can switch cursor to the completion pane and do standard search.

Reference Lookup

To lookup documentation of the word under cursor, type Ctrl+c Ctrl+r (“xahk-lookup-ahk-ref”). It'll switch you to the web browser of the function's documentation page at https://www.autohotkey.com/docs/AutoHotkey.htm

Customizing xahk-mode

“xahk-mode” follows emacs's convention of keyboard shortcuts. Many of them are not very convenient. If you prefer easier keys, or other conveniences, put the following code in your emacs init file “.emacs”.

(defun my-xahk-mode-customizations ()
  "Some customization for xahk-mode."
  (local-set-key (kbd "<f9>") 'xahk-lookup-ahk-ref)

(add-hook 'xahk-mode-hook 'my-xahk-mode-customizations)

Select the above code, then type Alt+x eval-buffer. Then, close any ahk files and re-open them. Or, you can just restart emacs.

I also recommend:

Bugs and Wishlist

There is another AHK mode, but that mode has some problems. See: Emacs AutoHotkey Mode Problems .


If you like it, please support by Buy Xah Emacs Tutorial Buy Xah Emacs Tutorial or make a donation. Thanks!

or, buy some nice keyboard from my site. Xah Keyboard Guide

See also: