Detect Indentation using 8-character indentation instead of 4 characters
See original GitHub issueEnvironment data
- VS Code version: 1.27.2
- Extension version (available under the Extensions sidebar): 2018.8.0
- OS and version: macOS 10.12.6
- Python version (& distribution if applicable, e.g. Anaconda): 3.6.5, Anaconda Intel build
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Relevant/affected Python packages and their versions: None
Actual behavior
Pressing return e.g. after a function signature (def somefunc():
) or tab (whether there is text selected or not) results in an indentation eight characters wide.
This appears to be specific to the contents of my code file as I cannot reproduce with a new Python file.
Expected behavior
Four-character indentation as per previous versions of vscode-python and PEP 8.
Steps to reproduce:
- Open a new file and save with
.py
extension. - Verify that
Settings
->Detect Indentation
is checked. - Paste in code from an existing Python file lasted edited with an earlier version of VS Code. See attached example.
- Press return or tab as indicated in description of actual behavior.
Steps that DO NOT reproduce:
- Open a new file and save with
.py
extension. - Verify that
Settings
->Detect Indentation
is checked. - Start typing. Indentation is four characters per keypress.
Unchecking Settings
-> Detect Indentation
does result in expected behavior.
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
##########Linting Output - pylint##########
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
[pylint
apparently doesn’t pick up on the 8-char indentation either?]
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
)
log.ts:159 INFO no standard startup: not just one window
TMSyntax.ts:47 Overwriting grammar scope name to file mapping for scope source.python.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json.
New grammar file: file:///Users/arg/.vscode/extensions/magicstack.magicpython-1.0.12/grammars/MagicPython.tmLanguage
e.register @ TMSyntax.ts:47
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to change indentation in Visual Studio Code?
Edit 1 · Step 1: Click on Preferences > Settings · Step 2: The setting you are looking for is "Detect Indentation", begin...
Read more >What's the deal with tab size (8 spaces) in the GitHub UI?
"Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even ......
Read more >Why is GitHub's default tab size 8 spaces instead of 4 ... - Quora
Spaces are always spaces. Spaces allow you to dictate the size, so you can have indents less that 8 characters, which is important...
Read more >VS Code tips — Indentation settings and the ... - YouTube
VS Code shows the indentation settings for the current in the status bar. Click on this entry to quickly change the tab size...
Read more >Indentation | IntelliJ IDEA Documentation - JetBrains
Use the tab or space character for indentation and code formatting. ... When the option is on, the part of indentation defined by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for pointing out that extension @karrtikr. It’s clearly popular, and probably will satisfy my use case.
I will leave this issue open in case the vscode-python team wishes to incorporate this functionality at some future point (which would not be unusual in the Python world; perhaps microservices are still favored in JS/TS applications?)
Pylance now supports auto-indentation so this should no longer be an issue, if you still face it feel free to open up an issue on https://github.com/microsoft/pylance-release.