Search code examples
htmlsublimetext2phpstormsublimetext3sublimetext

Is there a fast way to paste consecutive numbers in multiple selection?


When working with HTML ids it is often necessary to create elements with same id names, but different numeric index, for example:

<ul>
   <li id="item-|"></li>
   <li id="item-|"></li>
   <li id="item-|"></li>
   <li id="item-|"></li>
   <li id="item-|"></li>
</ul>

"|" - represents one of the multiple cursors. Is there a way to paste numbers from 1-5 there?


Solution

  • For PhpStorm:

    You can use the String Manipulation plugin.

    To generate numbers in sequence at the multiple carets:

    1. Type in the number to start the sequence with, say 1, and then select the number.

    2. Open the String Manipulation menu. This is done by

      • Alt+M, or
      • Alt+Shift+M, or
      • Pull Down MenuEditString Manipulation.
    3. In the menu, choose Increment/DecrementCreate sequence.

    Here's an animated screenshot: Screenshot is based on PhpStorm 2016.2 and String Manipulation 5.0.135.445.0.