Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
MacGowans Teeth
Aug 13, 2003

Subjunctive posted:

Could you unpack that? Is q the macro name?

q is the register where the macro is stored. The normal command treats whatever comes after as if it had been typed on the current line in normal mode, so when you do that across a range, it applies the normal mode commands to each line in the range. I use :'<,'>norm (or numbered ranges) for . and & a lot, and it's great for macros, too. It's a pretty awesome command.

Adbot
ADBOT LOVES YOU

MacGowans Teeth
Aug 13, 2003

Destroyenator posted:

Combining with visual mode can be pretty powerful too:
code:
:g/{/norm f{v%J
All lines matching open brace ( :g/{/ ) normal mode ( norm ) jump forward to brace ( f{ ) enter visual [highlighting] mode ( v ) jump to matching brach ( % ) join all highlighted lines ( J )

You can chain multiple calls if you have an enter key press in a register. I can't work out how to paste one into the command line without having pre-recorded it though.
code:
:g/something/norm V/searchtarget^Md
All lines matching something ( :g/something/ ) normal mode ( norm ) line highlighting ( V ) search forward for searchtarget ( /searchtarget^M ) delete all highlighted lines ( d )
Where ^M is a pasted enter, to record one to register q ( qq<Enter>q ) and paste with control-r q.

:monocle: Whoa, using visual mode hadn't occurred to me, that's awesome.

  • Locked thread