Sublime Forum

Macros, Matching brackets and related

#1

:roll_eyes: (I’ve shortened my initial exasperation)

Often the record macro works as anticipated, however on saving, today certainly, it doesn’t. Having looked at the saved commands there does seem to be a discrepancy in what I’d imagine the commands to be, rather than what the saved commands are. Or the recorded macro when replayed isn’t the key presses I’ve just pressed and therefore not the expected behaviour.

A concrete example:

                    if (current_Level<10 )
			{
				++current_Level;
				xMAX.X_boundry(current_Level);
				yMAX.Y_boundry(current_Level);
				x = MIN;
				y = MIN;
			}

(Sorry this is a copy and paste out of ST3)
I’ve managed to get a macro to work to delete the if statement and accompanying { }, however I’m trying a get a macro to work to just comment out the if structure. Having succeeded with the delete one would think the comment would be possible…
I’m using the match bracket command (ctrl+m) but it seems to miss the last bracket when recorded as a macro. (the playback with ctrl+alt+q doesn’t)
When I hit stop recording says I’ve recorded 34 or 15 or 94 commands when I’ve only done 6 or so key presses. Is this something to do with how ST3 stores movement, BOL or EOL etc ?
Have also been adding bookmarks so I can “de-comment” the comments, again that works for something small, but I tried “de-commenting” as part of a larger macro and it doesn’t work…

I suppose I could use multicommand to do this, but the point of macros is that they’re much “quicker” (ha,ha) and “easier”. I’m clearly not the first to say this but the macro situation does need sorting, please, please, please.

Any way, any thoughts, plugin suggestion, or how I might use multicommand for this one would be much appreciated. Right, off to comment out all those if statements by hand, O first world problems !

:stuck_out_tongue_closed_eyes:

0 Likes

#2

Why not just use ctrl + / to comment out lines. Why do you require a macro for that ?

0 Likes

#3

Because if one has more than two “if statements” to comment out, or if there’s many lines between the opening and closing brackets (ie a big if statement with a lot of code) in that if statement; or a combination of the previous scenarios, it’s a lot of key presses. As previously mentioned I’ve manage to “automate” deleting an if statement (but leaving the code in it intact) but there seems to be trouble recording a macro with a comment, when in this scenario…

0 Likes