Skip to content

Instantly share code, notes, and snippets.

@gzagatti
Created March 26, 2018 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzagatti/352cb19ab8303b52fa19efcc20f423bc to your computer and use it in GitHub Desktop.
Save gzagatti/352cb19ab8303b52fa19efcc20f423bc to your computer and use it in GitHub Desktop.
capture search to a variable for later re-use in Vim

The expression below captures the first group match and adds its to a list for later use.

let t =[] | '<,'>s/\v\\code\{([^}]+)}\zs/\=add(t, submatch(1))[1:0]/g

We can then place the list into another section of the file with.

put = t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment