开发者

Automatic correction of python sphinx line length

开发者 https://www.devze.com 2023-03-07 23:24 出处:网络
Usually, best practices related to sphinx says t开发者_C百科hat you must limit the line length to less than 80 characters.

Usually, best practices related to sphinx says t开发者_C百科hat you must limit the line length to less than 80 characters.

So I want a way to automatically limit my line length to less than 80 characters (with no hyphens) and when the correction happens, it has to put the correct indent (if possible). The only function I've seen who seems to fit a bit is the Textwrap http://docs.python.org/library/textwrap.html Someone has some experiences with this? a better idea maybe? The function is already bundle in sphinx but I don't find it ? I miss a topic in stackoverflow?

Any input is welcome.


A descent editor is what you need.

In vim for example this is handled by doing:

:set textwidth=80

Then all you have to do is start typing and vim will continue on the nextline.

Marking text and doing a gq reformats the selection according to the setting of the "textwidth" variable.

Ex.

In those days spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri.

In vim after setting tw=30, selecting text and doing a gq:

In those days spirits were
brave, the stakes were high,
men were real men, women were
real women and small furry
creatures from Alpha Centauri
were real small furry
creatures from Alpha Centauri.
0

精彩评论

暂无评论...
验证码 换一张
取 消