Author Topic: How to indent whitespace in selection?  (Read 1302 times)

Offline Kahenraz

  • Single posting newcomer
  • *
  • Posts: 6
How to indent whitespace in selection?
« on: February 19, 2019, 10:27:48 am »
When I select a block of text and perform an indentation with tab, I want the whitespace to indent along with it. The reason for this is that I want my cursor to remain within the same horizontal block as I cursor down through the code. It bothers me that it truncates all the way to the left.

I can't seem to find a way to do this in Code::Blocks. Is there a setting for something like this?

Thank you.

« Last Edit: February 19, 2019, 10:29:33 am by Kahenraz »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12595
    • Travis build status
Re: How to indent whitespace in selection?
« Reply #1 on: February 19, 2019, 08:20:50 pm »
Can you try to give a better explanation? I'm not sure what the problem is...

You want the cursor to move with the indentation?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: How to indent whitespace in selection?
« Reply #2 on: February 20, 2019, 09:17:15 am »
I think the problem is in line 11 (empty line), it doesn't indent when you select with multiple lines and press tab.

Offline Kahenraz

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to indent whitespace in selection?
« Reply #3 on: February 20, 2019, 12:30:17 pm »
I think the problem is in line 11 (empty line), it doesn't indent when you select with multiple lines and press tab.

This is correct. I want the whitespace of my selection to be indented along with the rest of the code.

Offline sodev

  • Regular
  • ***
  • Posts: 380
Re: How to indent whitespace in selection?
« Reply #4 on: February 20, 2019, 03:28:53 pm »
Does not every IDE these days by default remove trailing whitespace? And isnt this a good thing for git and the like?

Offline Kahenraz

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to indent whitespace in selection?
« Reply #5 on: February 21, 2019, 04:26:12 am »
Not if it directly contradicts a coding style. Every time I indent something, I have to manually cursor around and indent the whitespace.

I don't have this problem on Eclipse as it will both indent whitespace in selections as well as with the code style formatter. The same goes for any of my other editors.

This is my first time using Code::Blocks and I was very surprised as this behavior.

As far as Git is concerned, it is a non-issue either way as it has options natively to ignore whitespace changes.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6894
    • My Best Post
Re: How to indent whitespace in selection?
« Reply #6 on: February 21, 2019, 02:53:45 pm »
Did you make sure that "Strip Trailing Blanks" is unchecked.

It then works for me once I have the spaces indented once; does not change zero spaces on a line.
Edit2: It looks like you already noticed this.

Settings -> Editor
Tab: Editor Setting
Section: End of Line options

Tim S.



« Last Edit: February 21, 2019, 03:03:03 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Kahenraz

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to indent whitespace in selection?
« Reply #7 on: February 22, 2019, 01:25:23 am »
The problem seems to be that the IDE will not indent lines which are empty.

Can an option be added to allow this? Is this behavior that can be modified by a plugin?

Thank you.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12595
    • Travis build status
Re: How to indent whitespace in selection?
« Reply #8 on: February 22, 2019, 08:53:34 am »
I doubt a plugin can do this. I tested scite and geany and both editors behave the same as codeblocks, so I think the change should be introduced in scintilla's Indent function (Editor::Indent).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]