Wednesday, June 19, 2013

Column selection in Sublimetext using alt + left click

Many editors use alt + left click to do column selection. In Sublimetext the default is middle mouse button or shift + right click. To use alt + left click, create a file Data\Packages\User\Default (Windows).sublime-mousemap (or equivalent if different OS), with the following contents:
[
 {
  "button": "button1", "modifiers": ["alt"],
  "press_command": "drag_select",
  "press_args": {"by": "columns"}
 },
 {
  "button": "button1", "modifiers": ["alt", "ctrl"],
  "press_command": "drag_select",
  "press_args": {"by": "columns", "additive": true}
 }
]

Tuesday, January 29, 2013

Lorem ipsum hotkey

Here's an AutoHotKey script to generate "lorem ipsum" when you press scroll lock. If you press again within a second it also inserts a space and avoids title-casing the word.
SetKeyDelay, -1

lipsum = Lorem ipsum dolor sit amet consectetur adipiscing elit sed et suscipit nunc in egestas velit condimentum nunc egestas feugiat nunc scelerisque tincidunt nisi vitae aliquet in eget tortor mauris sed porttitor velit quisque vehicula pretium rutrum vestibulum nec quam lectus et eleifend nibh morbi placerat facilisis ante quis elementum quisque a lacus velit

StringSplit, lipsum_array, lipsum, %A_Space%

n := 1
t := 0

ScrollLock::
    if n > %lipsum_array0%
    {
        n := 1
    }

    word := lipsum_array%n%

    t2 := DllCall("GetTickCount64")
    if ((t2 - 1000) < t) {
        send {space}
    } else {
        StringUpper, word, word, T
    }

    send %word%

    n := n + 1
    t := DllCall("GetTickCount64")
return