4

Is there a way to make the automatic line wrapping of vim aware of the syntax of the file instead of just wrapping at the closest whitespace? I am specifically interested in Python but I guess it would be more or less the same for most other languages.

Let's give an example to illustrate the problem. The following line is too long for my settings (max. 79 characters per line):

some_variable_with_a_very_long_name = a_function_with_a_very_long_name(argument_with_long_name)

When typing, it automatically gets wrapped when reaching the limit. However, it can only wrap at whitespaces, i.e. the result looks as follows:

some_variable_with_a_very_long_name =
a_function_with_a_very_long_name(argument_with_long_name)

This does not look nice and for Python it is even invalid syntax. What I would like to achieve is something like this:

some_variable_with_a_very_long_name = a_function_with_a_very_long_name(
    argument_with_long_name)

A similar issue is that it should not wrap inside a string.

Your Answer

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

Browse other questions tagged or ask your own question.