michel lompret
michel lompret

Reputation: 317

Replace by a list in Sublime Text 2

I want to replace a list of the word flipInY with a different word for each occurrence. For example, I have this:

flipInY flipInY flipInY flipInY flipInY flipInY flipInY flipInY flipInY flipInY

I want it to become this:

bounce flash pulse rubberBand shake headShake swing tada wobble jello

Is there a way to do this automatically with Sublime?

Upvotes: 3

Views: 1303

Answers (1)

Frank Tan
Frank Tan

Reputation: 4412

You can do this with a series of built-in shortcuts.

  1. Type your list into the editor, with each item on its own line:

    bounce
    flash
    pulse
    rubberBand
    shake
    headShake
    swing
    tada
    wobble
    jello
    
  2. Select all (Ctrl + A / Super + A).

  3. Split selection into lines (Ctrl + Shift + L / Super + Shift + L). This creates a cursor on each line. In your case, you should have 10 cursors.
  4. Copy.
  5. In the file with all the flipInYs, find and select every instance. You can do this by opening the find panel, typing in flipInY, and clicking Find All (or alt+enter). Note that this won't work unless you have the same number of occurrences of flipInY. In your case, there should be 10.
  6. Paste.

Upvotes: 6

Related Questions