While coding in Matlab
, I had the option of smart indenting my code using the shortcut Ctrl+i. Is there a similar option for Python
using Notepad++
?
Specifically, I am looking for a solution to the following problem:
I want the block
line 1
line 2
line 3
to be converted to
line 1
line 2
line 3
On a side-note, I found this to be surprisingly easy with SE editor (keyboard shortcut: Ctrl+k). I want this feature to be available for other languages as well (in my experience good indentation hasn't killed anyone, regardless of the language).
Just select the text you want indented and hit Tab. To un-indent, select the text and hit Shift+Tab.
If you're in "Normal text file" mode, this will give you tabs (\t
characters). If, however, you're in Python mode (which you enter either by saving as a .py
file or by selecting Python from the Language menu), it should default to using four spaces instead of tabs. To configure the way tabs work yourself, go to Settings → Preferences → Tab Settings (for Python, this should default to "Tab size: 4" with "Replace by space" checked).
Select all 3 lines and hit the Tab key. To undo this action you can hold down Shift while pressing the Tab key.
Pro Tip: As long as you have at least 2 lines partially selected, you can tab in the entire block.
Example:
If you want to change tab settings there are two locations in Settings -> Preferences
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With