For example, there is a line:

print('value of 1 variable: ' + var1) 

And it is necessary to successively copy such lines N times in order to achieve :

 print('value of 1 variable: ' + var1) ... print('value of N variable: ' + varN) 

Is there a native way in emacs in order not to manually change the numbers in the strings and variable names? If so, can you do the same things, only use a function or a list of variables instead of a primitive auto-increment ?

    1 answer 1

    This is easily implemented with macros .

    Go to the beginning of the line:

     print('value of variable: ' + var) ^ 

    And run: Ck <F3> Cy Cb Cx Ck <TAB> Ce Cm <F4> Cu 5 Cx e to generate 5 auto-increment rows:

     print('value of variable: ' + var0) print('value of variable: ' + var1) print('value of variable: ' + var2) print('value of variable: ' + var3) print('value of variable: ' + var4) 

    The documentation also describes how to include elisp code in macros to implement more complex logic.