Skip to content

Instantly share code, notes, and snippets.

@adam000
Last active August 23, 2018 20:47
Show Gist options
  • Save adam000/0d4f48b3f24415b657073cb734338b75 to your computer and use it in GitHub Desktop.
Save adam000/0d4f48b3f24415b657073cb734338b75 to your computer and use it in GitHub Desktop.
MARS - Macroized Applied Rapid Substitution
// :execute "normal" "mAj^W\"nyEW\"ayEW\"byEk" | execute "normal" @n . "k" | execute ".,.+" . @n . "s/" . @a . "/" . @b | execute "normal" "'A"
// 25 FooApi BarApi
// Explanation:
// mark line as A mA
// down one line j
// beginning of content ^
// next Word W
// Copy Word to n, continue \"nyEW
// Copy Word to a, continue \"ayEW
// Copy Word to b \"byE
// Up one line k
// Up register n lines @n . "k"
// In the next n lines, sub a for b ".,.+" . @n . "s/" . @a . "/" . @b
// Go back to the line at the start 'A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment