Indent/unindent blocks of code

Skydiver

Well-known member
Joined
Apr 6, 2019
Messages
461
Location
Virginia Beach, VA
Programming Experience
10+
If I use the editor toolbar to open the Insert Code dialogue, paste a block of with leading whitespace, select the code and then press Shift+Tab, the whitespace is trimmed such that the least-indented line(s) is left-aligned and all other indenting is maintained.
So I see part of the issue. I was using the the code BB tags, and then pasting in my code in between the begin and end-tags and then trying to do the Shift+Tab to try to unindent the block.

Unfortunately, with the "Insert Code" dialog, I'm only seeing the first line of the block being unindented.

So I go open the Insert Code dialog, and type in the following:
C#:
    oaeuaouo
    aoeuaoua
    oaeuaeoua
    oaeuaouaoeu
Then I press, Ctrl-A to select all. Then lastly I press Shift+Tab. Only the first line of the selected block is unindented. (If I press Tab, instead of Shift+Tab, the entire block correctly gets indented.)
 

Sheepings

Senior Programmer
Joined
Sep 5, 2018
Messages
466
Location
UK
Programming Experience
10+
I just checked it, and you're using the same version of opera as me.

You need to use actual code and not what you've quoted. In the Insert code blocks, it will only indent the first line. But not if you use actual code.

The simple solution is not to trim the white space when copying code.
 

Sheepings

Senior Programmer
Joined
Sep 5, 2018
Messages
466
Location
UK
Programming Experience
10+
Confirming it also works on Edge too, and so I will assume it will work on Chrome ;)
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
2,431
Location
Sydney, Australia
Programming Experience
10+
The simple solution is not to trim the white space when copying code.
Actually, the simple solution is to trim the whitespace when copying the code but to do so for the whole block rather than just the first line, which I see a ton of people do for some reason. Many people don't realise that you can hold down the Alt key while selecting text to select an arbitrary rectangular block, so if you start somewhere in from the left edge, the selection will start at the same column on every line.
 
Last edited:

Sheepings

Senior Programmer
Joined
Sep 5, 2018
Messages
466
Location
UK
Programming Experience
10+
Hmm I will have to check that out when I'm next in the IDE. I never have any issue posting. I always select a block and leave the indentation intact on every line.
 

Skydiver

Well-known member
Joined
Apr 6, 2019
Messages
461
Location
Virginia Beach, VA
Programming Experience
10+
Not all text editors implement the rectangular block text copying, but yes, I get the sentiment.
 
Top Bottom