gotgenes
gotgenes

Reputation: 40029

Configure where Vim breaks long lines

How does Vim determine where to break lines when they exceed textwidth, and how can I control this behavior? For example, typing

a = really_long_function_call(some_super_long_parameter_name_that_i_want_wrapped

with set textwidth=72 results in

a =
really_long_function_call(some_super_long_parameter_name_that_i_want_wrapped

when what I want is to supply more sophisticated logic that would break the line on the opening parenthesis of the call, e.g.,

a = really_long_function_call(
        some_super_long_parameter_name_that_i_want_wrapped

Upvotes: 2

Views: 63

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172510

This is explained at :help 'textwidth':

Maximum width of text that is being inserted. A longer line will be broken after white space to get this width.

To get around this, you'd have to write a function that performs the text break, and install it via the 'formatexpr' option. I haven't seen this used so far, and the help is also shy on this, so some effort is required here.

Note that for visual-only, soft wrapping, you can influence where it happens, via :set wrap linebreak breakat=...

Upvotes: 1

Related Questions