Emacs AutoHotkey Mode

By Xah Lee. Date: . Last updated: .

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


github https://github.com/xahlee/xahk-mode.el

or MELPA. 〔►see Emacs: How to Install Packages Using ELPA, MELPA, Marmalade



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【Esc 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 www.autohotkey.com.

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 Ahk Mode Problems.


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

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