skip to Main Content

enter image description here

The code was copy-pasted from outside. I would like to see if I can format this with <indentation with tab size 2>, but my VSCode doesn’t want to do that. It draws the lines for the tab size 2 indentation, but doesn’t actually format the code in that manner.

On the other hand, somehow it does good job with JS files, but just not with Python files. I’m using autopep8. Is it because I am using autopep8 and autopep8 doesn’t let me change indentation easily?

Thanks!

2

Answers


  1. Python can’t be auto formatted because the logic is indentation dependent

    • select the 4 spaces before the def on line 2
    • use Ctrl+D as many times until you reach before return
    • type: Space Space
    • exit Multi Cursor: Esc
    Login or Signup to reply.
  2. It looks like you have set tabsze to 2 spaces, if you want the indentation of each line to be one tab (2 spaces):

    1. Select the lines you want to remove indentation
    2. press Ctrl+[

    Also if you want to add indentation, use Ctrl+] or Tab

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search