Sublime Forum

Replacing a number with same number +1?

#1

Hi to all.

I’d like to take a block of lines which have numbers ranging from 1 onwards and replace the numbers such that they have 1 added (not inserted!) to them. I have:

global.ar_arc[1,1]=room_test_bg
global.ar_arc[1,2]=global.info_part_bg //partial info
global.ar_arc[1,3]=global.info_full_bg //empty//oinfo_full.bg //full info
global.ar_arc[1,4]=780 //empty
global.ar_arc[1,5]=240 //empty
global.ar_arc[1,6]=global.info_map_bg //empty
global.ar_arc[1,7]=5//x position on arc select screen.
global.ar_arc[1,8]=0 //row on arc select screen. 0 = top row, 1 = bottom row
global.ar_arc[1,9]=0 //empty
global.ar_arc[1,10]=global.title_sel_head_bg
global.ar_arc[1,11]=global.title_sel_sub_bg

I’d like to replace the numbers in the second column of the 2x1 matrices above so they are +1 the original number. For example, the [1,9] should become [1,10], the [1,10] becomes [1,11], [1,11] becomes [1,12] etc.

Is there any way to do this using the Replace Function? I’ve tried searching for such a function but keep running into functions that deal with inserting numbers, rather than adding to what I already have.

Thanks for any help!

0 Likes

#2

https://packagecontrol.io/packages/Inc-Dec-Value

alt+ctrl+down to select column after comma, ctrl+shift+right to select until the bracket, then alt+up

1 Like

#3

Thanks for the quick reply mg979!

I’ve installed the plugin. I’m having some difficulty in actually getting it to work. Pressing alt+ctrl+down seems to flip my screen upside down (I’m using Windows 7). Is there some other combination of keys needed to select the column? Also, will this work for double digits (since the second digit is the next column and would result in 10 becoming 20 instead of 11)?

Thanks again!

0 Likes

#4

You could use shift+right mouse button to select a column, also https://packagecontrol.io/packages/Column%20Select can help. And maybe find a way to stop win7 stealing your key bindings because it’s not worth it.

1 Like

#5

You can also do this using python expressions in InsertNums. Make a selection on each of your numbers you want to increase, e.g. using a regular expression search, open the InsertNums panel and insert i|_+1.

1 Like

#6

https://packagecontrol.io/packages/Insert%20Nums

but also

https://packagecontrol.io/packages/Text%20Pastry (maybe easier to use)

You still need to select the column though…:slight_smile:

1 Like