简体   繁体   中英

How to use tabs-as-spaces in Python in Visual Studio 2008?

I have some IronPython scripts that are embedded in a C# project, and it would be convenient to be able to edit them in the VS editor. VS evidently knows about Python because it provides syntax coloring for it. Unfortunately however the editor uses tab characters for indentation, whereas I want spaces. Is there a setting to change this? I don't see a heading for Python under Tools/Options/TextEditor.

Here is one way to do it, probably not the best. On the Tools -> Text Editor -> File extension part of the Options menu add a .py extension, and set an type of editor. You don't get a python editor type, but you can pick one of the ones you use less often (for me this would be VB.net), and then make sure that the tab settings for that language fit your needs. Syntax highlighting didn't seem to be affected for me.

Tools -> Options -> Text Editor -> Choose Language ( you might need to choose All Languages )

Click on Tabs and set it how you want it.

Edit: Looks like you can add your own file types in the same area and set Tab setting specifically for them.

Only the print command is able to read such functions properly in python . so, a tab command can be used along with the print command. To get a space when one uses a tab function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM