Is there any way to get vim to auto wrap python strings at 79 chars?

后端 未结 1 2002
庸人自扰
庸人自扰 2020-12-04 12:35

I found this answer about wrapping strings using parens extremely useful, but is there a way in Vim to make this happen automatically? I want to be within a string, typing

相关标签:
1条回答
  • 2020-12-04 12:55

    More a direction than a solution.

    Use 'formatexpr' or 'formatprg'. When a line exceeds 'textwidth' and passes the criteria set by the 'formatoptions' these are used (if set) to break the line. The only real difference is that 'formatexpr' is a vimscript expression, while 'formatprg' filters the line through an exterior program.

    So if you know of a formatter that can do this transformation to lines of python code, or are willing to write one, this will give you a hook to have it executed. And since vim supports python (see :help python) you can even write your python formatter in python.

    0 讨论(0)
提交回复
热议问题