Detect Indentation

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 453
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Detect Indentation

Post by Sicro »

I work with many third-party codes that have their own indentation style:
  • Tab as indentation character: Tab length: 2, 4 or 8 spaces
  • Space as indentation character: 2, 4 or 8 spaces
When I edit these codes, however, my indentation style specified in the PB editor is used and a mix of different indentation styles is created.

It would be good if the PB editor would optionally analyze the code after opening to detect the indentation style and temporarily adjust the indentation for this code accordingly.

https://code.visualstudio.com/docs/edit ... odetection
Image
Why OpenSource should have a license :: DarkColor-Scheme for PureBasic
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: Windows 7 x64 (VirtualBox) :: Newest PureBasic version
User avatar
Demivec
Addict
Addict
Posts: 3818
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Detect Indentation

Post by Demivec »

You can create a tool that cönverts the idents on load/save.
Image
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 453
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Detect Indentation

Post by Sicro »

Yes, but then I have to re-program the PB editor's identation processing myself again, not just the identation style's detection function.

Currently I imagine the indentation of the line continuations difficult. But maybe I'm wrong and it's not that hard.
Image
Why OpenSource should have a license :: DarkColor-Scheme for PureBasic
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: Windows 7 x64 (VirtualBox) :: Newest PureBasic version
User avatar
Derren
Enthusiast
Enthusiast
Posts: 305
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Detect Indentation

Post by Derren »

You just need to press Ctrl+A and then Ctrl+i and the IDE reformats the entire file using your preferred indentation.

Seemingly it also works if another type of indentation is used.
I have a real tab, with size 4 as indentation. And this code (with lots of different amounts of spaces) formats properly using the above-mentioned key combo.

Code: Select all

Procedure test(a.i)
    If a=#True		
  Debug "true"
         Else
  Debug a
      EndIf 	
   EndProcedure
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 453
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Detect Indentation

Post by Sicro »

Derren wrote:You just need to press Ctrl+A and then Ctrl+i and the IDE reformats the entire file using your preferred indentation.
I am aware of this function. However, I don't want to change the indentation to my preferred indentation style, but to keep the indentation style of the current code.

I could temporarily change the indentation style in the PB settings according to the current code, but what do I do if I have multiple codes open in the PB IDE at the same time that have different indentation styles?

I am still for a native implementation of this requested feature.
Image
Why OpenSource should have a license :: DarkColor-Scheme for PureBasic
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: Windows 7 x64 (VirtualBox) :: Newest PureBasic version
Post Reply