Lets say I have a list of code like this

foo <- "test"
foo <- "test"
foo <- "test"
foo <- "test"
foo <- "test"
foo <- "test"
foo <- "test"
foo <- "test"
foo <- "test"
foo <- “test"

Is it possible to automate the insertion of columns of numbers. The output should be this:

foo1 <- "test1"
foo2 <- "test2"
foo3 <- "test3"
foo4 <- "test4"
foo5 <- "test5"
foo6 <- "test6"
foo7 <- "test7"
foo8 <- "test8"
foo9 <- "test9"
foo10 <- “test10”

Is there perhaps a regex or other automation that could be used? I’m aware that it is possible to insert line numbers but this will only be useful if the 10 lines of code happen to be on lines 1-10.

Thanks
Ross