Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to let PyCharm auto break line when writing long docstrings and comments?

Writing long docstrings and long comments is annoying because of the 80-characters width limit.

For example, I write something like:

def fun(self):
    """Return some thing

    This function do some complex work and return something that need a
    long sentence to describe
    """

And then I found I need to insert something in the third line of docstring. After inserting, the width is much longer than 80 characters, so I manually break it. However, after breaking, the length of forth line is much less than 80, and I have to merge the forth and fifth line, and break it at some proper place so that every line is not too short and too long. If there are more lines, this job gets more annoying.

Similar problem occurs when I found I have to delete something in the third line. Is there any trick, or plugin of PyCharm that deals with this problem? Since I'm using vim plugin in PyCharm, tricks for vim are also great.

like image 930
iuradz Avatar asked Mar 22 '16 09:03

iuradz


People also ask

How do you fix the line too long in Pycharm?

To configure the line length, open settings Ctrl+Alt+S , navigate to Editor | Code Style, and type the necessary length in the Hard wrap at N columns field.

How do I automatically add a docstring in Pycharm?

Press Ctrl+Alt+S and go to Editor | General |Smart Keys. Select the Insert type placeholders checkbox in the Smart Keys page of the editor settings. Place the caret at the function name, and press Alt+Enter . In the list of intention actions that opens, choose Insert documentation string stub.

How do you write notes in Pycharm?

Press Ctrl+Alt+S to open the IDE settings and select Editor | General | Smart Keys. In the Enter section, select or clear Insert documentation comment stub checkbox. Then, expand the Smart Keys node and select Python. Use the Insert type placeholders in the documentation comment stub option as required.


1 Answers

Edit -> Fill Paragraph

Merges a paragraph, i.e. a text region without a blank line between.

If you want it to leave text alone you need a blank line between it and the text where the focus is

like image 74
Peter Wood Avatar answered Nov 15 '22 19:11

Peter Wood