Sublime Forum

Video Tip: Creating n copies of a template with varying data

#1

I’ve found myself repeatedly with a multi-line template that I need multiple copies of, but I need to customize each template with one or more values specific to that template. This has happened both in XML as well as real code.

Instead of copy/pasting the template n times and then filling out each copy, here’s a video tip showing how I accomplish this goal in Sublime:
screencast.com/t/SIoNoUOx5i

Roughly explained:

  1. Create one line for each of the custom data that will go into each template copy.

  2. Copy the template onto the clipboard.

  3. Create one selection region at the start of each custom data line.

  4. Paste. This creates one multi-line template copy for each bit of custom data interleaved with your data, leaving you with multiple selection regions.

  5. Cut your custom data and then move into the template and paste and edit as appropriate.

If your custom data uses different number of characters, the key to using this to good effect is to use home/end after moving to a new line to ensure that you’re in a consistent location, and then use ctrl+arrow keys to move by words instead of characters.

0 Likes