Skip to content

Instantly share code, notes, and snippets.

@MattBroyles
Last active February 3, 2016 19:24
Show Gist options
  • Save MattBroyles/060b9996fb0ace25e60e to your computer and use it in GitHub Desktop.
Save MattBroyles/060b9996fb0ace25e60e to your computer and use it in GitHub Desktop.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
#IfWinActive ahk_class PX_WINDOW_CLASS
; keypress detection for enter
Enter::
if counter >= 0 ;setTimer already started, so log keypress
{
counter++
return
}
counter = 0 ; start timer and set number of logged keypresses to 0
setTimer, keyWinEnter, 400
return
KeyWinEnter:
setTimer, KeyWinEnter, off
if counter = 0
{
Send {Enter}
}
if counter = 1
{
Send {End}{Enter}
}
counter = -1
return
#IfWinActive
@MattBroyles
Copy link
Author

This AHK script lets you break out a line of text and insert a new line on the same indent level without splitting your current line. For example, when editing HTML, rather than having to hit the arrow key or the end key to go to the end of the current line, and then hitting enter in order to insert a new line, when you are finished editing between the tags, merely hitting enter will accomplish the same thing. This scrip only targets Sublime Text as-is, however using Windows Spy, simply replace ahk_class with whatever you wish to target and re-run it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment