Home Download Buy Blog Forum Support

Questions about macros.

Questions about macros.

Postby Plus on Fri Jun 29, 2012 7:10 pm


Imagine this task: I want to find and remove all commented lines in a Python file.
Something like this:

1. Find commented line (regexp search for "^#").
2. Delete it (by pressing Ctrl+Shift+K).
3. Repeat until the end of file.

I would like to use a macro for this task, but it seems like I'm unable to - macro recording ignores
search request and just removes lines without finding anything.

Also, there was a question on the forum some time ago, about repeating a macro -
is there a way to quickly repeat a macro a specified number of times? And it was proposed to just select
the lines of interest, split the selection into lines and replay the macro.
But what if we want to run a macro for, say, each third line in a huge file containg thousands of lines?
It seems impractical to do this by manually selecting said lines.

Posts: 2
Joined: Fri Jun 29, 2012 7:05 pm

Re: Questions about macros.

Postby C0D312 on Fri Jun 29, 2012 8:59 pm

Unfortunately, ST2 macros are not very powerful. You cannot repeat x times. You cannot use find/replace. Fortunately, plugins are very simple to make.

http://docs.sublimetext.info/en/latest/ ... acros.html
http://docs.sublimetext.info/en/latest/ ... ugins.html
Posts: 1056
Joined: Sun Jul 10, 2011 3:23 am

Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 30 guests