r/ProgrammerTIL • • Nov 01 '19
Other TIL That selecting a block of code and pressing tab or shift + tab will indent/move back all of the code in most IDEs
166
Upvotes
r/ProgrammerTIL • • Nov 01 '19
11
u/[deleted] Nov 01 '19
Also, highlight a block and ctrl-/ will comment/uncomment the block.
34
u/baerz Nov 01 '19
Visual Studio has a command to auto-format the whole file according to configurable rules, the default hotkey is CTRL + K, CTRL +D. It fixes all indentation automatically and I'm sure most other IDEs have something equivalent. It's very helpful
10
u/captain_wiggles_ Nov 01 '19
Checkout multiline editting, I use this so often.
In notepad++ (assuming you've enabled it in the settings) you can either hold ctrl and click with the mouse to insert cursors where you want. Or you can hold shift and alt and select a block of text. Once you've got either one you can type to all cursors (or lines in the block) at once, you can paste to all of them, and delete / backspace etc..
If you use ctrl + click, you can even use the arrow keys to move arround, and all cursors stay at fixed distances, and inserting new lines works as you want. But you have to use the mouse which is a bit annoying, and one bad click means you have to start again.
I use this all the time.
4
u/Axmirza2 Nov 02 '19
In vim you can do gg = G to fix the entire file's indentation
2
u/[deleted] Nov 28 '19
All decent text editors, not just IDEs, have this feature.
1
u/Gotta_Ketcham_All Nov 02 '19
In IntelliJ you can highlight words and press the quotation mark key and it will enclose that text in quotes too. Works for double quotes and single quotes.
0
u/botle Nov 02 '19
I wish I could do something similar to move a block of code on tab to the left.