Search code examples
visual-studio-codeindentationshortcut

How to add 4 spaces indent to all lines in VS Code?


I am using VS Code for Python development.

BranchList=['BD','WE','BB','GB','MB']
if lastMonth[-2:]=='01':
    month='Jan'
elif lastMonth[-2:]=='02':
    month='Feb'
elif lastMonth[-2:]=='03':
    month='Mar'
elif lastMonth[-2:]=='04':
    month='Apr'
........

If I want to use 'try: except' to catch the exception(add a try: before the 1st row), all the rows below the 'try: ' should have additional 4 spaces indent. It's a very big manual work to add the 4 spaces indent for every rows. Is there any quick way to do it in VS Code?


Solution

  • If you highlight all the rows and press Tab, they should all indent. Shift+Tab will deindent.