Insert Incremental numbers in Intellij

Edit: check below for new solution

Quick tip. If you're used to the Text-Pastry or Increment Selection plugins in Sublime Text, then there's finally a way to do it in Intellij and it's sisters (like WebStorm or PHPStrom) using the plugin String Manipulation.

It's a bit different from ST. You need to write your starting numbers first:

System.out.println("Here 1");  
System.out.println("Here 1");  
System.out.println("Here 1");  
System.out.println("Here 1");  

Then select the numbers with multiple selection and activate the Create Sequence command to get this:

System.out.println("Here 1");  
System.out.println("Here 2");  
System.out.println("Here 3");  
System.out.println("Here 4");  

YES!! Was missing this so much. There are also issues open about this, but my needs are now met.

Solution 2

Turns out live templates do this trick for debugging purposes even better.

  1. Open Settings -> Editor -> Live Templates
  2. Create new template
  3. Insert these values
    Template text is console.log("$file$:$line$ $method$()");.
  4. Click on Change and add Javascript to the context.
  5. Click on Edit Variables and insert these
  6. Close settings
  7. In your editor write log and press tab. You'll now get the filename, line number and method name all in one go, even with multiple cursors!

Krister Viirsaar

Read more posts by this author.

Subscribe to Krister's coding adventures

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!