How to expand text for free with AutoHotkey

Microsoft Windows only. No install required.

TL;DR: For each text expansion, add a line in your AutoHotkey script file of the form ::abbrev::text to expand “abbrev” into “text” whenever you type it. (Be sure to save the file & reload it in AutoHotkey after you make your change.) Grab a book to learn how to show/hide windows, and launch programs quickly or read more or more.

Step by Step Instructions for Expanding Text


Step 1: Install, no admin requiredInstall AutoHotkey (even without admin rights). It’s available free-of-charge from AutoHotkey.comDetailed instructions available here.

Step 2: Open the script for editing: Assuming you’ve followed my instructions, open your AutoHotkey script file for editing by pressing Shift-F5. If you didn’t follow my steps, find the green “H” icon in your Windows taskbar and right-click on it, and click ‘Edit This Script’.

Step 3: Create text expansion: Insert a basic text expansion such as

::hw::Hello World

on a blank line of the file and save it.

Step 4: Refresh AutoHotkey: Reload the file by pressing Ctrl-F5 (if you followed my instructions) or by right-clicking on the green “H” icon in your taskbar and selecting “Reload This Script”.

Step 5: Test your expansion: Now you should be able to type ‘hw’ into any text field and have it expand to ‘Hello World’, once you press the Space or Enter key.

Read next: How to Quickly Insert the Current Date or Time Using AutoHotkey.

If you find this article interesting, grab a free sample of my 5-star ebook to learn more. All code and examples available for free on this very website.

Why is this useful?

You can:

  • Save your wrists and hands; type less, get more done.
  • Rapidly write polite, full-sentence e-mails with only a few keystrokes.
  • Always spell people’s name’s right: ‘js’ becomes ‘John Smith’ or ‘djs’ becomes ‘Dear John’.
  • Code HTML a lot by hand in a legacy CMS? Use AutoHotkey to close and open tags for you: </p becomes </p> <p> - complete with newlines and proper indentation.
  • Insert your address or zip code into webforms quickly
  • Always spell words correctly - let the computer remember how to spell them for you: ‘maint’ becomes ‘maintenance’.
  • Have boilerplate that you always need to put in a report or e-mail? Let AutoHotkey type that paragraph in for you.

See more benefits to using AutoHotkey.

AutoHotkey Text Expansion Reference

Basic Text Expansion

The basic form of text expansion with AutoHotKey is two colons, followed by the abbreviation you want to use, followed by two more colons, followed by the text you want to replace the abbreviation with:

::abbreviationlt::Here is some really long text that will appear whenever I type 'abbreviationlt'. In real life I'd use something like tahke for Tortured AutoHotKey Example.

When you use this form of abbreviation AutoHotkey expects you to type an ending character to indicate that you have completed typing and that, yes, you finished typing an abbreviation that you expect AutoHotkey to expand.

However, sometimes you want AutoHotkey to expand text right away, as soon as you type an expansion trigger (a ‘hotstring’ in AutoHotkey parlance).

Advanced Expansion

By default, AutoHotkey does not expand text right away (in case your hotstring happens to be part of a word) and waits until you type an ending character (such as a space, a right paren, or press the Enter key, etc.). However, you can have AutoHotkey expand your text as soon as the text you’re typing matches a defined abbreviation (your ‘hotstring’), if you’re not in the middle of a word:

:*:rightnow::Expand this text RIGHT AWAY please, AutoHotkey.

This is the same form we used above – with the exception of an asterisk between the first set of colons. The form is a colon, followed by an asterisk, followed by a colon, followed by the abbreviation you want to use, followed by two colons, followed by the text you want the abbreviation to expand into.

If you want AutoHotkey to expand text even if that text occurs as part of a word then you should use define your abbreviations as follows (add a question mark between the first set of colons):

:?:lain::Expand me even in the middle of a word that contains the text 'lain' eg. the word 'explain', which would become really long.

If you want AutoHotkey to expand text no matter what, then you should define your abbreviation this way (use a question mark AND an asterisk):

:?*:always::Always expand this hotstring, even if I'm in the middle of a word OR if I don't type an endchar; just always expand this text whenever you see it.

If you found this article useful, check out my 5-star ebook Practical AutoHotkey: How to get faster at work with text expansion and automation (Amazon Kindle). The examples and a brief AutoHotkey reference section are available on this website for free. 

Originally published March 2016.

You may also like: