Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Please implement indentation for Unreal engine 4

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
baron1990 Posted - Sep 20 2019 : 6:14:16 PM
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.
6   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Dec 20 2019 : 2:37:04 PM
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
feline Posted - Sep 23 2019 : 07:10:38 AM
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.
baron1990 Posted - Sep 21 2019 : 2:24:25 PM
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
feline Posted - Sep 21 2019 : 10:17:56 AM
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.
baron1990 Posted - Sep 20 2019 : 8:37:59 PM
Great, thank you for consideration!
ChrisG Posted - Sep 20 2019 : 6:26:58 PM
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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000