Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Please implement indentation for Unreal engine 4
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

baron1990
New Member

4 Posts

Posted - Sep 20 2019 :  6:14:16 PM  Show Profile  Reply with Quote
By default Visual Studio smart indentation will indent when you hit new line after UE4 macro.

for example:
UPROPERTY()
->->->DataType Var;

however smart indent should not work for unreal macros, so the result should be following instead:

UPROPERTY()
DataType Var;


This is the only feature that VAX is missing with UE4 projects, and there is no alternative extension available.

edit:
I added ->->-> denoting a tab, in first example because forum indents my example.

Edited by - baron1990 on Sep 20 2019 6:16:08 PM

ChrisG
Whole Tomato Software

USA
299 Posts

Posted - Sep 20 2019 :  6:26:58 PM  Show Profile  Reply with Quote
We have this on our radar, and know it would be a helpful feature for UE developers. Even without the tabs I knew what you meant. I don't have a timeframe for implementation, but I have added your voice to the internal case.

Thanks for taking the time to make a suggestion.
Go to Top of Page

baron1990
New Member

4 Posts

Posted - Sep 20 2019 :  8:37:59 PM  Show Profile  Reply with Quote
Great, thank you for consideration!
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Sep 21 2019 :  10:17:56 AM  Show Profile  Reply with Quote
Have you considered doing a find and replace regular expression search in the IDE, to try and fix the indentation? The following regex find and replace seems reliable and accurate. I have tested this in VS2017, using the IDE's Find and Replace dialog, which has it's own version of regex syntax:

Find - ^([ \t]+)((UFUNCTION|UPROPERTY)\(.*)\n([ \t])+(\w)
Replace - $1$2\n$1$5

You just need to add any extra macro names to the (UFUNCTION|UPROPERTY) block for them to be picked up and handled the same way. The find and replace picks up the indent of the macro, and sets the following line to the same indent.

zen is the art of being at one with the two'ness
Go to Top of Page

baron1990
New Member

4 Posts

Posted - Sep 21 2019 :  2:24:25 PM  Show Profile  Reply with Quote
This regex hack is awesome! I tested it in VS 2019 and it works out of the box... I'm bookmarking this page :D

While I would definitely like to have indentation to be automatic and instant,
the trick with regex will save me from hitting backspace on every UFUNCTION / UPROPERTY declaration.

thanks a lot for sharing your knowledge!
I'll will immediately share this thread with community in unreal forums, wooha!!! :D
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Sep 23 2019 :  07:10:38 AM  Show Profile  Reply with Quote
I am glad it helps My knowledge of Unreal is very small and random, mainly from studying problems with VA parsing it, but it looks like changing the search regular expression to:

^([ \t]+)((UCLASS|UINTERFACE|USTRUCT|UFUNCTION|UPROPERTY)\(.*)\n([ \t])+(\w)

should catch all of the expected macros that will alter the indenting of your code.

Beyond this there are a couple of things to be aware of. Firstly this uses the Regex format of Visual Studio Find and Replace, which is different to every other regex format I am familiar with. So if you run this regex with a different tool the find will probably work fine, but the replace is likely to break.

Also you need to "reset" your Find and Replace settings every time you want to do this. In theory you should be able to write an IDE macro to save out the current find and replace settings, run this regex find and replace on the current file, and then restore the find and replace settings to what they were before. I know you can do this with older versions of Visual Studio, where macros were built in. For more recent versions you would have to try something like this extension:

https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MacrosforVisualStudio

and see if it would let you do this.

zen is the art of being at one with the two'ness
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Dec 20 2019 :  2:37:04 PM  Show Profile  Reply with Quote
Build 2358 has improvements in this area when typing but not for the format selection command.
https://support.wholetomato.com/default.asp?W404
http://builds.wholetomato.com/binaries/VA_X_Setup2358_0.exe
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000