1

I have multiple lines like this <VValue type="int" value="0" /> in files running in Sublime; each where the value increments 0, 1, 2, 3 etc...

I need to change these values, +60. So, 0 would become 60, 1 would be 61 etc.

How do I select the multiple lines and append them with regex in Sublime? I'm not sure of the command to select the number itself... something like \d+ was mentioned in another thread - Sublime Text 2 increment numbers

Note, I skip one number to separate some content in the software the files run in, so it really needs to be a +60 to the value command instead of just a direct replace all and increment (as in the thread above) as that would throw off the one that was skipped, if you follow me. For example, it could be 0, 1, 3, 4, 5 that should equal 60, 61, 63, 64, 65 and not 60, 61, 62, 63, 64.

Do I need something like TextPastry, and to use the Number Sequence Command? If so, I'm not sure how that works and would appreciate comments.

Thanks for any help :)

Edit; I think I can use the Auto Step feature in Text Pastry? Can someone kindly run me through this how to... install and use.

Community
  • 1
  • 1
Ashley Smith
  • 113
  • 2
  • 8

1 Answers1

6

Unfortunately, Text pastry is not powerful enough (as far as I know). You need some evaluator package. We'll use Sublime-Evaluate here.

To install it (assuming you have package manager installed) simply

Command+Shift+p -> ip -> Enter -> evaluate -> Enter


Now just select the numbers you want to change (search with regex enabled):
(?<=<VValue type="int" value=")\d+(?=" />)

Alt+Enter. Now they are selected.

Right arrow to go after the selection. Type +60. Now Ctrl+Shift+ 3 times to select

0+60
1+60
...
n+60

on each line. Now Command+Shift+e and you are done (alternatively, you can Command+Shift+p -> evaluate -> Enter.

ndnenkov
  • 35,425
  • 9
  • 72
  • 104
  • Awesome, gonna check this out. A little confused for installing it... I guess I download the zip, extract and then which file do I select or where to install it to so Sublime picks it up? Cheers, very much appreciated! :) – Ashley Smith Sep 28 '15 at 18:50
  • Ok, got it installed. I just have one issue... The `Ctrl`+`Shift`+n extends the selection past the />. For example it's extending it to just before the " of the next line... after false ` ` – Ashley Smith Sep 28 '15 at 18:57
  • Do I need to do find and replace or just find and find all with that regex command? Thanks for the help, family new to these types of commands in Sublime, but they're awesome and a huge time saver. – Ashley Smith Sep 28 '15 at 18:58
  • @AshleySmith, my bad, it should be `Alt`, not `Shift`, updated. – ndnenkov Sep 28 '15 at 18:58
  • @AshleySmith, findall (aka select all with multiple cursors). – ndnenkov Sep 28 '15 at 18:59
  • Sorry, not sure if increment is the right wording as it should be value plus 60. Do need to install SelectionRubyEval for this of can I do the `Ctrl`+`Alt`+`n`? Cheers for the help! – Ashley Smith Sep 28 '15 at 19:02
  • @AshleySmith, unfortunately, I do not know of a TextPastry command that lets you increment. But evaluators are great in text editors, they give you unlimited power. If you know ruby, `SelectionRubyEval` is a must. If not, there are other eval packages as well. – ndnenkov Sep 28 '15 at 19:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/90823/discussion-between-ashley-smith-and-ndn). – Ashley Smith Sep 28 '15 at 19:05
  • 1
    Man, this is insane. Thanks so much! – Minoru Feb 16 '17 at 13:25