Sublime Forum

Questions about macros

#1

Hello!

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.

Thanks!

0 Likes

#2

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

docs.sublimetext.info/en/latest/index.html
docs.sublimetext.info/en/latest/ … acros.html
docs.sublimetext.info/en/latest/ … ugins.html

0 Likes