ryuta46 / vscode-multi-command

Visual Studio Code Plugin named multi-command
MIT License
229 stars 14 forks source link

Paste boiler plate (python) (and multiline "text") #34

Open davidcsi opened 3 years ago

davidcsi commented 3 years ago

Hello,

I'm trying to create a command that simply prints out a boilerplate for python, so i'm doing this:

            "command": "multiCommand.pythonBoilerPlate",
            "sequence": [
                {
                    "command": "type", 
                    "args": {
                        "text": "#!/usr/bin/env python3\n\"\"\"\nModule Docstring\n\"\"\"\n\n__author__ = \"Your Name\"\n__version__ = \"0.1.0\"\n__license__ = \"MIT\"\n\ndef main():\n\"\"\" Main entry point of the app \"\"\"\n\tprint(\"hello world\")\n\nif __name__ == \"__main__\":\n\t\"\"\" This is executed when run from the command line \"\"\"\n\tmain()"
                    }
                }
            ]

and it's printing it, but i think vscode's auto-indent is messing it up, because it's printing the following:

#!/usr/bin/env python3
"""
Module Docstring
"""

__author__ = "Your Name"
__version__ = "0.1.0"
__license__ = "MIT"

def main():
""" Main entry point of the app """
    print("hello world")

    if __name__ == "__main__":
        """ This is executed when run from the command line """
            main()

After printing out the "print" statement, it's auto-indenting the rest... is there a solution for this? I already tried backspacing it with \b but that doesn't help.

Thanks!

prime31 commented 3 years ago

It sounds like you have some sort of auto formatter running perhaps? If you have a solid Python formatter maye just run it directly after the text is injected and let it handle getting those tabs in place correctly.