[Python] how to indent multiple lines proportionately in visual code [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 25, 2025.

  1. Stack

    Stack Membro Participativo

    I created a class in python that stores a database of ASCII art strings. I can do this reliably thanks to the triple quotation marks which allows me to use multiple lines. However, the problem with this is that when I attempt to paste the art into their designated variable name within the class, the art is left-aligned with the screen, and doesn't follow the same tab indention like everything else in the class (like I want it to, in other words). If I press Tab or Ctrl + ], it messes up the art by making sure that each line has has exactly 4 spaces, no less.. no more.. I want there to be at least 4 spaces, and if there is already a space between the first character and left side of the text editor window, to add the 4 spaces to it. I can do this manually, but it is quite the drag... any thoughts how to do this in Visual Code?

    # how it is when pasting
    mouseTalking = ("""
    _ _
    (q\_/p)
    /. .\\
    =\_V_/= __
    / \ (
    (( )) )
    /\) (/\ /
    \ Y /-'
    `""^""` """)

    # how I want it to be when pasted (indented)
    mouseTalking = ("""
    _ _
    (q\_/p)
    /. .\\
    =\_V_/= __
    / \ (
    (( )) )
    /\) (/\ /
    \ Y /-'
    `""^""` """)
    # what occurs when I indent it using Tab or Ctrl + ]
    mouseTalking = ("""
    _ _
    (q\_/p)
    /. .\\
    =\_V_/= __
    / \ (
    (( )) )
    /\) (/\ /
    \ Y /-'
    `""^""` """)

    Continue reading...

Compartilhe esta Página