3

How I can auto-format code inside lambda-functions?

I know this question asked here,

But the solution of the question didn't work in my case ↓ (maybe updated)

public SyncTableViewModel()
    {
        LoadCategoryCommand = new Command(o =>
        {
            Task.Run(() =>
            {

                Task.WaitAll(
                                Task.Run(async () =>
                                {
                                    //....
                                }),
                            Task.Run(async () =>
                            {
                                //....
                            }),
                        Task.Run(async () =>
                        {
                            //....
                        }));
            });
        });
    }

I wonder if there's an update to this in Visual Studio 2017 !?

or there is a shortcut to use it

such as Ctrl+k , Ctrl+D .

Anas Alweish
  • 2,818
  • 4
  • 30
  • 44

2 Answers2

0

Try to mark all the code after lambda expression and then Tab.

Sarah
  • 35
  • 1
  • 9
0

After many attempts, I found the solution:

Requirements: ReSharper

in Visual Studio

  • Open Tools > Options or press Alt + T + O
  • Under Environment tab > Keyboard
  • Search for "ReformatCode" and select Resharper.Resharper_ReformatCode
  • Add a new shortcut for example Ctrl+R,Ctrl+C
  • Assign > OK

you have two options

  • Choose the code and then press the shortcut
  • Press the shortcut and the command will be executed on the entire document

enter image description here

Anas Alweish
  • 2,818
  • 4
  • 30
  • 44