Adding spaces in multiple lines simultaneously - in Pycharm
Asked Answered
C

7

49

I occasionally need to go line-by line and change the indentation of the code.

Is there a shortcut in Pycharm where I can add spaces (format the indent) in the begining of multiple lines simultaneously without processing each line individually?

Cornia answered 18/7, 2014 at 10:25 Comment(0)
C
87

Highlight/ select the lines you want indented, then press TAB as often as needed until they reach the proper indent level.

You can remove spaces with SHIFT TAB.

You can also use CTRL+ALT+I to auto-indent the selection.

Choosy answered 19/7, 2014 at 6:41 Comment(6)
But what if the TAB makes 8 spaces instead of 4 which is what intended? Is there anyway to force it to move forward only by 4 spaces?Outgrowth
@Allan Tab Size is a setting under Settings -> Code Style -> the language you are usingChoosy
ctrl+alt+i is possibly the most useful keyboard shortcut I've ever learned.Ainslie
ctrl+alt+i doesn't work on my Windows machine, but TAB does.Camillecamilo
What if you want to add spaces that don't end up like CTRL + ALT + I ends up? as in if CTRL ALT I adds three spaces and I wanna add 4?Bookmobile
Go to tools and disable Vim emulator.Labium
L
19

Select the block that you want to indent then press TAB. It will work.

Laurinda answered 15/4, 2016 at 11:24 Comment(0)
Z
5

To auto indent all the codes in Pycharm just press these sequencies:

CTR + A to select all the text files and then press

CTRL+ALT+I

Zworykin answered 21/3, 2019 at 14:6 Comment(1)
What if you want to add spaces that don't end up like CTRL + ALT + I ends up? as in if CTRL ALT I adds three spaces and I wanna add 4?Bookmobile
S
1

Select all that you want to indent, then do CTRL+ALT+I to indent all of it. This should work in Pycharm

Spatial answered 25/10, 2019 at 21:58 Comment(1)
What if you want to add spaces that don't end up like CTRL + ALT + I ends up? as in if CTRL ALT I adds three spaces and I wanna add 4?Bookmobile
B
1

Use shift +alt on windows machine

Baobaobab answered 9/6, 2022 at 7:10 Comment(0)
T
0

Continuation indent for Mac pro: Preferences -> Editor -> Code Style -> the language -> Tabs and Indents

Theriault answered 13/10, 2022 at 7:19 Comment(0)
L
0

If Ctrl + ALT + I is not working and every time needs to press the Insert button to get the pointer.

So go to Tools -> Select Vim if it is checked then it will be disabled.

Now you can intend code directly selecting multiple lines.

Labium answered 7/2, 2023 at 18:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.