Is it possible to use a regular expression to alter an array index in emacs?
e.g. for some C code change:
int my_array[4];
my_array[0] = 1;
my_array[1] = 2;
my_array[2] = 3;
to:
int my_array[4];
my_array[1] = 1;
my_array[2] = 2;
my_array[3] = 3;
a sort of replace [i]
with [i+1]
operation?
Something like that ?
M-x query-replace-regexp my_array\[\([0-9]+\)\] RET my_array[\,(1+ \#1)]
\, in replacement string can be replaced by any lisp expression.
(last edit: using \#1
in place of (string-to-int \1)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With