Is is possible to create a macro that act on the current selection, or the current line if nothing is selected?
I realize I can create one to do one or the other, but I want one to handle both.
TextPad has a command to duplicate the current line, and I can easily make a macro to duplicate the current selection, but I to create one shortcut key to either (depending on if there is a selection or not). VS does this and I really like the feature.
Thanks.
Selction or Current Line Macro
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Sigh. Pedantry at it's best. When I RECORD a macro, I am CREATING a macro.AmigoJack wrote:Macros are recording, not creating.
That's plainly obvious or I wouldn't have asked. It doesn't mean someone hasn't devised a trick or two. The so-called "if/then" is a high-level construct. There are ways of doing a conditional that don't involve it.AmigoJack wrote:If the feature "select current line if nothing is selected yet" does not exist as an action you could choose from the menu, then you can't record it.
Macros are no scripts either, where you could insert conditions ("if ... then ...").
It's "its" (because "at it is best" makes no sense, while the determiner "its" expresses belonging to "best").Drxenos wrote:Pedantry at it's best.
Sure. But you don't create actions that otherwise aren't available - that's what "to record" implies. I was refering to actions, not macros itself.Drxenos wrote:When I RECORD a macro, I am CREATING a macro.
Too bad you keep it to yourself and tell it nobody, just because you seem to have a problem with me. Moreover you're able to edit posts instead of posting 2 replies in a row.Drxenos wrote:Ha! I've figured it out.
The secret is finding a command that behaves differently with selected lines vs none selected. I found that setting a bookmark fits the bill. When lines are selected, it marks all of them. If not, it marks the line the cursor's on. Plus, there is a command to copy all bookmarked lines to the clipboard. Perfect.ak47wong wrote:Drxenos, I'd be interested to know what solution you came up with.Drxenos wrote:I've figured it out. It can be done. It's not ideal, but it works.
Of course, the problem is you'll lose any bookmarks you currently have set. Also, it does "weird" things if the selected lines aren't fully selected. So...not so perfect, but functional. It can probably be refined...
All in all, what I currently have is:
BookmarkClearAll
BookmarkToggle
EditCopyTaggedLines
BookmarkClearAll
LineStart
EditPaste
I'd also found that if I create a simple macro (e.g., record a single keystroke), I can then just edit the macro manually, which is much easier than re-recording it for each test.
DrX