Skip to content

Instantly share code, notes, and snippets.

@Lokno
Created January 5, 2021 20:51
Show Gist options
  • Select an option

  • Save Lokno/7c5730d37c9dfe291578dcde0502e0d7 to your computer and use it in GitHub Desktop.

Select an option

Save Lokno/7c5730d37c9dfe291578dcde0502e0d7 to your computer and use it in GitHub Desktop.
AutoHotKey script that appends the correct suffix to an ordinal number
^d::
Send {+Home}
Send ^c
Send {End}
RegExMatch(clipboard, "(\d+)$", SubPat)
StringRight, lastDigit, SubPat, 1
if( SubPat == "11" || SubPat == "12" || SubPat == "13" )
{
Send, th
}
else if( lastDigit == "1" )
{
Send, st
}
else if( lastDigit == "2" )
{
Send, nd
}
else if( lastDigit == "3" )
{
Send, rd
}
else
{
Send, th
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment