Author Topic: Fixing Mixed Tabs and Spaces in C Source Code  (Read 1468 times)

bsun

  • Community Member
  • Posts: 12
  • Hero Points: 0
Fixing Mixed Tabs and Spaces in C Source Code
« on: December 09, 2024, 10:05:24 AM »
Hi,
The indentation of my C source files is inconsistent, mixing tabs and spaces.
How can I fix this and set a consistent indentation style (tabs or spaces) in SlickEdit?

Code: [Select]
main.c:195:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  195 |     if (!inode->i_cdev)
      |     ^~

Thanks in advance!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6996
  • Hero Points: 533
Re: Fixing Mixed Tabs and Spaces in C Source Code
« Reply #1 on: December 09, 2024, 01:07:40 PM »
You can use the beautifier

bsun

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: Fixing Mixed Tabs and Spaces in C Source Code
« Reply #2 on: December 09, 2024, 01:35:40 PM »
Thank you for the reply.
Do you mean "Tools -> Beautify"?
If yes, I still have one more question.
How can I set a consistent indentation when I press the "tab"?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6996
  • Hero Points: 533
Re: Fixing Mixed Tabs and Spaces in C Source Code
« Reply #3 on: December 09, 2024, 01:47:16 PM »
Yes I mean Tools>Beautify

If you have the Tabs size set to say 8 but the indent amount (Syntax indent) is 4, it's not possible for only tabs to be used. The Tab amount must be the same as the Syntax indent amount (4 and 4 is common but 8 and 8 isn't).

bsun

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: Fixing Mixed Tabs and Spaces in C Source Code
« Reply #4 on: December 09, 2024, 01:49:19 PM »
I want my Tabs size to be 4 (for all languages). Where can I find this configuration?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6996
  • Hero Points: 533
Re: Fixing Mixed Tabs and Spaces in C Source Code
« Reply #5 on: December 09, 2024, 02:02:21 PM »
Tools>Beautify>Edit Current Profile