Home > OS >  How to add line breaks for Python code that VS Code Intellisense will use
How to add line breaks for Python code that VS Code Intellisense will use

Time:10-06

There are similar questions for C# but this one is specifically about the Python Intellisense.

This text:

"""Create a Zendesk ticket with the given information.
    * The `description` is ???
    * The `body` is ???
    * Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

Will produce: Screenshot

But is there any way to do this without the *? Is there a less visible way to add line breaks to docstrings that will translate into Intellisense without becoming one continuous line of text like this?

"""Create a Zendesk ticket with the given information.
    The `description` is ???
    The `body` is ???
    Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

Will produce Intellisense that looks like this:

wrapped text screenshot

CodePudding user response:

Method one

Use \n newline at the end of a sentence

    """Create a Zendesk ticket with the given information. \n
    The `description` is ??? \n
    The `body` is ??? \n
    Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

enter image description here

Method two

Add spaces at the beginning of the sentence

    """Create a Zendesk ticket with the given information.
      The `description` is ???
        The `body` is ???
      Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

enter image description here

Method three

Add a blank line between every two lines (can be used in conjunction with method two)

    """Create a Zendesk ticket with the given information.
     The `description` is ???
    The `body` is ???

    Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

enter image description here

  • Related