Xu Wang
Xu Wang

Reputation: 10607

Vim: line-wrap based on commas, not word boundary

Suppose I have the following:

myfunction(arg1 = something, arg2 = blah, arg3 = yeah, arg4 = nowayxavi, arg5 = too long)

If I press gql, it turns into this:

myfunction(arg1 = something, arg2 = blah, arg3 = yeah, arg4 = nowayxavi, arg5 =
           too long)

That is nice, but I would prefer to have the following:

myfunction(arg1 = something, arg2 = blah, arg3 = yeah, arg4 = nowayxavi,
           arg5 = too long)

Is there a Vim setting that can achieve this?

Upvotes: 0

Views: 197

Answers (1)

leaf
leaf

Reputation: 1764

I suggest using this format

myfunction(arg1=something, arg2=blah, arg3=yeah, arg4=nowayxavi, arg5=too long, arg6=too long)

after formatting it will be

myfunction(arg1=something, arg2=blah, arg3=yeah, arg4=nowayxavi, arg5=too long,
           arg6=too long)

From PEP8 Style Guide, scroll down a litte and it says

Don't use spaces around the = sign when used to indicate a keyword argument or a default parameter value.

NOTE: there is a difference between wrap and format, wrap means to display a long line in two lines while format changes the long line to two lines in this situation.

Upvotes: 2

Related Questions