Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
davidcsi opened this issue Jan 21, 2021 · 1 comment
Open

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

davidcsi opened this issue Jan 21, 2021 · 1 comment

Comments

@davidcsi
Copy link

davidcsi commented Jan 21, 2021

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
Copy link

prime31 commented Jan 21, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants