Is it possible, or does some function exists, to get the equivalent of the alt-q command, but in programming?

Suppose I've just written this in python:

group_parser.add_argument('-n',nargs=1, default=5,
help='specifies how many missing entries in a row are allowed before the whole row gets omitted.')

The following is a rather long line. Is it possible to have some sort of automation for getting the following output?

parser.add_argument('-n',nargs=1, default=5, 
                    help='specifies how many ' +
                    'missing entries in a row ' +
                    'are allowed before the whole row gets ' +

In other words, a function that detects long input strings, and splits them up across multiple lines.

  • Obviously that kind of behaviour would be specific to each individual programming language. As a complete tangent, you might find the Keep Left formatting style an improvement when breaking lines. – phils Jul 15 '17 at 20:52

You should try multi-line. Out of the box it works sanely for many languages. You can cycle through many different indentation strategies.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.