How do I turn a long one-line list, such as
test_list = ['a0000000', 'b1111111', 'c2222222', 'd3333333', 'e4444444', 'f5555555', 'g6666666']
into a one element per line list:
test_list = ['a0000000',
'b1111111',
'c2222222',
'd3333333',
'e4444444',
'f5555555',
'g6666666']
Or:
test_list = [
'a0000000',
'b1111111',
'c2222222',
'd3333333',
'e4444444',
'f5555555',
'g6666666',
]
With fill-paragraph
long one-line lists are at least broken up into multiline lists:
test_list = ['a0000000', 'b1111111', 'c2222222', 'd3333333',
'e4444444', 'f5555555', 'g6666666' ]
But I would find a one element per line list in many cases more useful. Is anyone aware of such a elisp function (e.g. in elpy or anywhere else)?
Black
formats it accordig to PEP guidlines. And I found most of the time, it does so with 1 value per line. The other possibility I see, is for you to try out macros. Do it one time with the first element, select the rest and set the cursor correctly for the second one. Then runapply-macro-to-region-lines
. You will probably fail the first time, but it's a good way to learn. – Swedgin Nov 25 '20 at 15:01