How can I configure ReSharper's code cleanup on save?

前端 未结 8 1716
时光取名叫无心
时光取名叫无心 2020-12-08 13:56

I would love to configure Visual Studio/ReSharper to run \"Code cleanup\" whenever I save a file.

A bonus would be to configure this only for C# files, as I sometime

相关标签:
8条回答
  • 2020-12-08 14:24

    In version 2020.2+ of R# there is now build in option to run cleanup on save:

    Resharper Options > Code Editing > Code Cleanup > General

    0 讨论(0)
  • 2020-12-08 14:24

    If you are on VS2012, and you can't use the macro solution, you could use AutoHotKey (or similar) to automate it, instead of using macros:

    1. In Visual Studio:
      1. Assign a key to the ReSharper_SilentCleanupCode command, e.g: CONTRL+SHIFT+C
      2. Change the save key from being CONTROL+S to something else, e.g: CONTRL+SHIFT+S
    2. In AutoHotKey create a snippet that looks something like that:

      ^s::
          Send, ^+c
          Sleep, 300
          Send, ^+s
      return
      
    0 讨论(0)
提交回复
热议问题