Sublime Forum

SublimeText macros are no good

#1

Is it just me or does the macro feature of sublime text really stink?

It does not even capture things like find next or add caret to selection…

Pretty much every worthwhile macro task involves and find of some sort…

1 Like

#2


2 Likes

#3

I realize that the macro don’t record commands! So unless you are just recording actual simple text manipulation, macro doesn’t work. I find this to be a massive short coming of sublime.

Compared to what you can do with Vim macros, sublime is macros are basically useless.

0 Likes

#4

You can always write a plugin…

It’s in python, it’s easy, and you can do much more stuff than in a macro

Matt

4 Likes

Author's thoughts on Open Source
#5

You can even write your own macro implementation :wink:

3 Likes

Author's thoughts on Open Source
#6

Yes, but recording a macro (if it work as expected) would be by far simpler than creating a plugin. I’d have to learn Python, the Sublime API, how to install and debug a plugin, …

0 Likes

#7

Can I intercept all keyboard events (and forward them to their original bindings)? Or do all commands already implement a command ‘object’ (for undo/redo) that I can access from a plugin (but then: why aren’t they already recorded by the current implementation)?

0 Likes

#8

You can create an EventListener object and implement the on_text_command and on_window_command endpoints to capture commands as they’re happening (along with their arguments). Despite the name, on_window_command captures ApplicationCommand commands as well.

A simple implementation could record the commands and their arguments to replay what the user did, in theory.

In the case of Undo/Redo, that’s a function of the edit object passed to the run method of TextCommand instances. The only way to modify a buffer is via a call that takes an edit object. Under the hood Sublime uses that to track changes.

Currently only TextCommand commands can be recorded in a macro, which is why some things don’t get recorded during Macro recording (or why you can’t manually create a macro file with those kinds of commands in it).

Only @jps knows why the current macro support only supports TextCommand commends though.

1 Like

#9

So we are all in agreeance then…Sublime macro system sucks?

About writing my own…I don’t know anything about the api, but I am willing to be, the fact that there is no popular plugin solution probably alludes to the fact that there are some deeper rooted limitations at play here.

But sure I can write my own plugins for almost every editor out there…

0 Likes

#10

Please share the plugin with us if you are sucessful…

1 Like

#11

I’ve been using Textpad and then Notepad++ for years and switched to Sublime on the recommendation of a friend.
I was totally dumbfounded when I found out that there is no support for find/replace in macro’s.
Seriously, what’s the point of not supporting something as rudimentary as find/replace in a macro?
Looking back, I see that this has been an issue for ever.
Is there an add-on that I can use to record macros that support find and replace in the mean-time? This is a Big Deal, to me as I use macros’s do some some pretty complex work. I’m just glad I didn’t uninstall Notepad++

1 Like

#12

Sublime has an alternative “macro” system that supports all built-in features, arbitrarily complex logic, and literally anything your computer can do. The Python API is so powerful and easy to use that I don’t see the point of actual macros. Frankly, I see them as a dubious vestige of TextMate compatibility rather than a valuable feature in their own right, and I wouldn’t expect any significant new development of this obsolete functionality.

If you’ve never written a Sublime plugin, you owe it to yourself to do it at least once. It’s super-easy. I have written a useful complete plugin in less than fifteen minutes start-to-finish in front of an audience. Custom Sublime plugins will change your life.

7 Likes

#13

Not sure which kind of complex work you need to do, but RegReplace is something which might be used to create complex find/replace templates based on regex. Those templates might be called from macros the same way as all available built-in or plugin commands can be.

I didn’t ever feel happy with macros in Notpad++ and I don’t in ST. But @ThomSmith stated the big advantage of ST over Notepad++ already. With some little effort in learning pyhton, you can create much more comprehensive “macros” to help you with your dayly life as you would ever be with Notepad++ (except digging into its C-API and create a C-plugin).

0 Likes

#14

By the way, I didn’t post this (was saved as a draft), strange things supported by macros, like saving bookmarks, should be implemented only after find and replace has been implemented, in my opinion. I’d rather be able to record find and replace using macros rather than save bookmarks! Then again, maybe implementing bookmarks into macros was a simple task, which is why it was done, who knows. I wish Jon would comment on this.

1 Like

#15

well it was never made possible for the find/replace string to be set from a plugin/macro:

1 Like

#16
0 Likes

#17

I posted in the previous thread on this subject about a year ago, and have mentioned it in other posts too. A number of people are chiming in with the position that extensions are more powerful than macros, which obviates the need for macros to record things like Find/Replace. I sit firmly on the side of the argument that macros should record everything that makes sense, with a few documented exceptions that should also make sense.

While I agree that extensions are more powerful and can always do the work of a macro - though I feel that Sublime’s API needs some work to really unleash that power - they’re no substitute for macros. The reason is simple: Being programmers, we would rather avoid having to write more programs to achieve sophisticated editing operations wherever possible. For many of us, Python and Sublime’s API are not our primary programming environment so the process can become overly time consuming. The editor is there to save us time and make complex editing operations a breeze. Extensions are useful where we might want to do something complex, repeatedly over time and with necessary logic that might change based on a variety of conditions or variables. Such functionality will often be useful to others. Macros should allow us to record a sequence of operations by doing them, optionally allow refinement by editing the macro’s code, then allow macro playback to be triggered with a keystroke.

The power of a programmer’s editor becomes evident to most when they discover the ability to build complex editing operations out of simple building blocks. Originally a Brief user whose editor of evolved through Emacs, Vim and Crisp for many years (I still use the latter), the ability to record and repeat a series of operations, including and beyond text entry and cursor movements, and play them back with a keystroke or say ‘repeat playback 20 times or until EOF’, is a workflow that can surmount complex editing tasks over large files in record speed. While Sublime’s multi-cursors and multi-selections can get you to the same place in some cases, it often can’t. So I’m left falling back to Crisp as others fall back to Notepad++ etc. to do such things - and that’s a real shame.

Many ask why this is the case. I don’t have insight into Jon’s design choices but I am a programmer, and the reason seems fairly obvious. Jon engineered macros to sequence simple keystroke-based operations like text entry, deletion and cursor movement into atomic language specific operations. Any text editor will need a wealth of these, and a dumb ‘sequencer’ which avoids functional code seems a logical, quick to implement approach. Beyond actual keystrokes, TextCommands are the lowest level operations falling into this category so Jon implemented the facility this way. Adding other types of function adds complexity because they might potentially affect the state of entire buffers, require input etc… So if I’m right the reason is simplicity, justified perhaps by the thinking that multi-cursors/selections would be an alternative workflow to the same ends.

With the time that’s passed it’s become clear that, while useful, multi-cursors/selections are not a panacea for the challenges of complex editing tasks. We need macros that can record and playback everything, which can then be used in extensions or as part of eg. ‘repeat X times or until EOF’.

Addressing Sublime’s key limitations should probably be high on the priority pile moving forward. For me, more powerful macros that record everything, and extensions that can do more by virtue of a richer API should be right at the top of the list.

:slight_smile:

5 Likes

#18

This seems to me to be the heart of the issue. I respect this position, having once been in it myself. But after using Sublime Text for several years, I feel that it is impossible to take full advantage of it without being willing and able to write new commands. I realize that it can take a while to become accustomed to making a new command a first resort, but for me, the time spent has been well worth it.

I half-agree with your conclusion — I have my own wish list of new API-accessible features. But personally, I would be a little disappointed if a new feature on that list were not implemented because the devs spent their time taking an existing feature that’s already exposed by the API and adding another redundant way to use it.

1 Like

#19

@qgates Addressing Sublime’s key limitations should probably be high on the priority pile moving forward. For me, more powerful macros that record everything, and extensions that can do more by virtue of a richer API should be right at the top of the list.

I agree with you, but in my opinion, what should be the top of the are the bug fixing:

  1. Starting with crash bugs. The editor should never crash. At lest for me. The same police apply to my Operating System, it should never crash (blue screen of death). I am very happy to be able to use my OS 180 days continually with no crashes. Means I can trust my computer stability and never loose my work (powered by nobreak, of course, as the light goes out sometimes in that long).
  2. Performance is also an essence. The editor should be fast. Eclipse, Netbeans, JetBrains Family, etc, too much slow. Hurts to open then, to ask something from them. They just don’t get it. You end up waist more time waiting for they to answer you, then actually working. However they have some more fancy features as organize imports, error checking etc. So sometimes when I am short of time and need just something fast, I keep them both open with Sublime, then when I need to compile, I minimize Sublime and press play on they fancy interface.
  3. Memory leaks. No memory leaks please. It understandable to use lots of memory when you use lots of features, but keeping eating until 15GB is not nice. But it is understandable. May be you are using so many features you need all that.

I am not saying Sublime Text does all that. Recently Sublime Text seems not to:

  1. To be crashing. The other day it crashed while I was typing a plain text, but I forgot to let it create a dump file. But since then it is all good.
  2. Its performance is awesome, it opens fast, closes fast, lots of speed for it. However it is hanging some seconds when I am opening some special syntaxes as the Shell Script, for the first time. Probably it is loading the syntax, etc. When it really bothers, I am going to look into it.
  3. Does not seem to be leaking memory, the other day it got on 1GB with not files opened, but probably related to how many syntaxes it got loaded and what its packages where saving on memory. For now, this not seems to be bothering.

I use Sublime Text because it has really powerful text features, and it is damn fast. Initially using Eclise & company, but they are too slow, after some years, they got really disgusting. So I started using Notepad++, which is pretty fast. But lacked the fuzzy auto completion and project management. Then I started try everything out there. But the only thing really fast and powerful as Notepad++, was Sublime Text. But even better, it runs on Linux and Windows :slight_smile:

@ThomSmith I feel that it is impossible to take full advantage of it without being willing and able to write new commands.

I think, from very far from the other editors, is that Sublime Text allow you to create your own commands. So, yes the full advantage is to write your own commands, therefore it can be wherever you would like it to be. Be your own editor, with your own fingerprint.

@qgates The editor is there to save us time and make complex editing operations a breeze. Extensions are useful where we might want to do something complex, repeatedly over time and with necessary logic that might change based on a variety of conditions or variables. Such functionality will often be useful to others. Macros should allow us to record a sequence of operations by doing them, optionally allow refinement by editing the macro’s code, then allow macro playback to be triggered with a keystroke.

Well, I barely new macros existed on Sublime Text. I’ve using a long time ago this other macro recorder:

  1. http://www.macro-expert.com/

May be that third part app can help you. To do mass editions I have been using some packages as:

  1. https://github.com/ehuss/Sublime-Column-Select
  2. https://github.com/philippotto/Sublime-MultiEditUtils

And regular expressions with find replace like (\s*)(word1)(\s*)(word2) -> \1\4\3\2.

@qgates For many of us, Python and Sublime’s API are not our primary programming environment so the process can become overly time consuming.

Indeed, is pretty time consuming writing new commands. But there are a lot of new commands already written out there. You could inspire and reuse. For now I have been writing some general commands which I can reuse over and over again.

1 Like

#20

I just ran into this issue today while working with a very large file that was consistently formatted and perfect for macro use. I wasn’t as surprised to find that the search functionality wasn’t supported, but I was very superposed to find that find_under and find_under_prev weren’t supported.

I really can’t think of a scenario where the current macros would be helpful.

Before Sublime I used Notepad++ and found myself using macros all the time. After switching to Sublime my macro needs almost disappeared because of multiple cursors and find_under. But there have been a few times that they were exactly what I needed.

I can say that booting a windows VM, installing notepad++ for the first time in 6 years, and re-learning it’s macro functionality was undoubtedly faster than figuring out plugins.

0 Likes