Incremental renaming any text editor

Using you favourite text editor (I use PHP storm and VSCODE)
Is there a feature to incremental renaming  while multi selecting here is pseudo desired output.
var1
var2
var3
var4
ar5
Note:there will be code in between which does not need changing imagine it's a JSON file and all I wan to do is change the id number incrementally.
Daniel LowesPHP Web Developer And Computer TechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongSoftware Team LeadCommented:
and all I wan to do is change the id number incrementally.

can you provide an example for clearer explanation?
Daniel LowesPHP Web Developer And Computer TechAuthor Commented:
suppose we have this code and assume it has many variables:
<?php 
$var= "cat";
$var="horse";
$Var="animal";
?>

Open in new window



I want to easily edit the number to get this result
,I already know how to edit multiple lines at once,.
but with the same piece of text..
So assume I selected all the lines at once and with some magic shortcut I got this:
<?php 
$var1= "cat";
$var2="horse";
$Var3="animal";
?>

Open in new window

Ryan ChongSoftware Team LeadCommented:
I can't find another tool to do such replacement but I would try this using an Excel maco:

Function SetTextWithRunningNumber(ByVal Content As String, ByVal FindText As String)
    Dim tmp As String, RunningNumber As Integer
    tmp = Content
    RunningNumber = 1
    Do While tmp <> ""
        If InStr(1, tmp, FindText, vbTextCompare) > 0 Then
            SetTextWithRunningNumber = SetTextWithRunningNumber & Left(tmp, InStr(1, tmp, FindText, vbTextCompare) - 1) & FindText & RunningNumber
            tmp = Mid(tmp, InStr(1, tmp, FindText, vbTextCompare) + Len(FindText))
            RunningNumber = RunningNumber + 1
        Else
            SetTextWithRunningNumber = SetTextWithRunningNumber & tmp
            Exit Do
        End If
    Loop
End Function

Open in new window


try like:

= SetTextWithRunningNumber(B2,"var")

Open in new window


once output is generated, copy and paste it to the editor you needed.
29129995.xlsm
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Zakaria AcharkiAnalyst DeveloperCommented:
You could use sublime text for this, follow these steps :

1. Open Sublime Text 3
2. Make sure you have Package Control installed (https://sublime.wbond.net/installation)
3. Press CTRL + SHIFT + P
4. Type Install onto the dialog window
5. Select “Package Control: Install Package” and press “Enter”
6. Search for and install “Increment Selection”
7. Select lines you want by keep pressing “ctrl” and select with “left mouse click”
8. Then press “ctrl” + “alt” + “i”
9. Boom, it will auto-increment each line 1,2,3,4 etc.

Tested solution.
Source : https://rricketts.com/add-auto-incrementing-number-selection-sublime-text-3/
Zakaria AcharkiAnalyst DeveloperCommented:
Here is the solution for PHPStorm :

1. First of all, make sure you can select multiple lines :

  • Go to setting.
  • Keymap.
  • Search for "Clone Caret Above" & "Clone Caret Below" then give them keymap you want to use.
  • Save changes.

2- Start Selecting :

  • Select the lines you want.
  • Then type '0' and you will have a bunch of zeros.
  • Press shift+left to select them all.
  • Then ctrl+shift+a and type 'Create Sequence'.
  • Chose it, AND YES, You have a series of digits.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Daniel LowesPHP Web Developer And Computer TechAuthor Commented:
Thank you Ryan Chong for thinking outside of the box and using excel.
Thank you Zakaria Acharki for focusing on PHPstorm .
Zakaria Acharki note to myself and other experts out there;
We need to install the string manipulation plugin
Zakaria AcharkiAnalyst DeveloperCommented:
You're welcome, glad to help Daniel, and thanks for adding the missing part in your comment.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.