Home Download Buy Blog Forum Support

Keyboard Macros

Keyboard Macros

Postby FunkyELF on Wed May 22, 2013 2:25 pm


I'm coming from being a big NEdit user. One of the reasons I use that program is for its excellent macro support.

I have tried using Sublime Text Macros for a little bit and am a bit frustrated.
Perhaps I am doing something wrong.

Here is an example I'm trying to do. Can someone help show me the Sublime Text equivalent of doing the following.

Lets say I have the following text.
I want to line up all of the colons and the values.
This is something I do very often in NEdit

Code: Select all
data = {
    'zero': 0,
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4,
    'five': 5,
    'six': 6,
    'seven': 7,
    'eight': 8,
    'nine': 9

In NEdit to make all of the colons line up I would do the following.
I'd start my cursor at the beginning of the 'zero' line (all the way or right by the single quote; doesn't matter).
1) Start recording a macro (alt+k)
2) find a colon (ctrl+f, colon, enter)... this leaves the editor with the first colon on that line selected.
3) dismiss dialog (esc)
4) press left arrow to get cursor to the left of the colon
5) select from there to the end of the line (shift+end)
6) cut (ctrl+x)
7) insert a bunch of spaces for padding (like 20 or so)
8) press home to go to beginning of line.
9) press right arrow a bunch of times (like 20 or so). This brings the cursor to the same position no matter where the initial colon was because we went home first.
10) paste (ctrl+v)
11) trim extra space off end (shift+end, then delete)
12) go on to beginning of next line (home, down)
13) end macro (alt+k)

I can then repeat the macro until the end of the Python dictionary.
I end up with the following, which I can do a rectangular selection and delete the whitespace to bring the values closer to the keys while leaving them lined up.

Code: Select all
data = {
    'zero'          : 0,
    'one'           : 1,
    'two'           : 2,
    'three'         : 3,
    'four'          : 4,
    'five'          : 5,
    'six'           : 6,
    'seven'         : 7,
    'eight'         : 8,
    'nine'          : 9

How can I do something similar in Sublime Text2.
I do the equivalent keystrokes but when I play them back weird things happen.
Posts: 1
Joined: Wed May 22, 2013 2:07 pm

Re: Keyboard Macros

Postby skuroda on Wed May 22, 2013 11:21 pm

As far as I can tell, ST doesn't handle non view commands very well. In ST, find would probably be classified as a window command. Not a macro, but have you tried out the AlignTab or Alignment plugins? Think those will both do what you want.
Posts: 692
Joined: Fri Oct 05, 2012 8:11 am

Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 27 guests