Assuming you are editing a file recognized by Vim as source code and therefore Vim's more sophisticated indenting is enabled1 (check with
:set cindent?) you can just do this:
:set textwidth=50 I get this formatting of your example line:
foo = long_function_name(var_one, var_two,
cinoptions allows you to tune how Vim indents various code constructs.
(N option is described, in part, in
:h cino-( thusly...
(N ... When N is 0 or the unclosed parentheses
is the first non-white character in its line, line up with the
next non-white character after the unclosed parentheses.
But for this particular case the help for
:h cino-W) actually has a (counter) example that is more in line with your case:
WN When in unclosed parentheses and N is non-zero and either
using "(0" or "u0" ...
We want it to look like the example on the left so
Take a look at
:h cinoptions-values for heaps of other ways to tune the indentation.
1 This doesn't apply to all languages. See the comments/chat for discussion about Python files having
nocindent by default.