ReSharper Tips and Tricks

Skip to end of metadata
Go to start of metadata

Redirection Notice

Icon

Core functions and performance

  • To disable/enable ReSharper, go to Tools | Options | ReSharper and click Suspend/Resume. If you want to have a shortcut that quickly switches ReSharper on and off, go to Tools | Options | Environment | Keyboard and find the ReSharper_ToggleSuspended command, then press some shortcut keys and click Assign.
  • Feel like ReSharper slows down your coding? Try increasing completion display time in ReSharper | Options | Environment | IntelliSense | Completion Behavior
  • If you deploy ReSharper in an organization, you can use JetBrains License Server for distribution of licenses.

Look and feel

  • You can change colors for everything ReSharper adds into Visual Studio. Go to Tools | Options | Environment | Fonts and Colors and find items starting with ReSharper
  • You can change ReSharper keyboard bindings for any action. Go to Tools | Options | Environment | Keyboard and find items starting with ReSharper
  • In Visual Studio 2012, you can use the Quick Launch feature to search and execute ReSharper commands.
  • Trying to learn ReSharper shortcuts? You can see most of them in ReSharper menu, you can view all keymaps online, or download and print a PDF version of shortcuts.

Coding in the editor

  • Do you want to surround some code with a try...catch? Use Ctrl+E,U (Ctrl+Alt+J in IntelliJ IDEA scheme). Learn to use other code templates available with this shortcut.
  • You can select a block of code and use Ctrl+Alt+Shift+ Arrow keys to move this block around.
  • You can view recent clipboard entries with Ctrl+Shift+V (ReSharper | Edit | Paste) and select the one you want to paste 
  • If you open parameter info (Ctrl+Shift+Space in the Visual Studio keymap or Ctrl+P in the IntelliJ IDEA keymap), you can use tab/Shift+Tab to jump to next/previous argument.
  • Enums Completion in ReSharper is CamelHump Powered, Middle Matching and Case Insensitive. Try typing StringComparison c = oic
  • Enum IntelliSense in ReSharper will automatically insert the Enum type as the prefix. No need to spell it out!
  • With String.Format, you can now add a placeholder where the cursor is. Just hit Alt+Enter in position
  • If a string literal is too long, hit Enter and ReSharper will automatically put the part of it to the next line and insert a + sign. Delete the + and the string parts will be concatenated.
  • Moving a property up 3 lines using cut/paste? There is a simpler way to do it: place your cursor on the property, press Ctrl+Shift+Alt and use the up arrow key.
  • Want to move a string literal to a resource file? Press Ctrl+Shift+R anywhere on the string and select Move To Resource.

Analyzing code

  • Using [NotNull] and [CanBeNull] attributes can help you find NullReferenceException before even compiling
  • Right-click on a file, project, solution folder or entire solution  in Solution Explorer and select Inspect Code to see warnings and suggestions for the selected item.
  • Don't need a particular inspection? Press Alt+Enter while you at the corresponding code and select Inspection Options, then you can choose to suppress it with comment or change its severity level to Do not show.
  • Starting from ReSharper 8.0, you can disable all inspections with a single comment — instead of defining separate inspections to suppress, you can now mark code with // ReSharper disable all and ReSharper will not complain about anything until it meets a corresponding // ReSharper restore all.
  • ReSharper's solution-wide analysis resolves visibility issues: you'll see if an internal member is used outside of its assembly and you'll never miss a single unused non-private member
  • You can exclude files by masks from code analysis (such as generated code) in ReSharper | Options | Code Inspections | Generated Code.
  • You can go to the next error by pressing Shift+Alt+PgDn in Visual Studio keymap or Alt+F12 in IntelliJ IDEA keymap.

Traversing code

  • Place your caret on the 'using' (or import if you work with VB.NET) keyword of the using directive. Right-click and choose Find Usages. ReSharper will show where exactly this namespace is used.
  • Forgot where you were editing just now? Go to last edit location with Ctrl+Shift+BackSpace
  • Want to locate a method or symbol real fast? Use Alt+{}  in Visual Studio keymap or Ctrl+F12 in IntelliJ IDEA keymap
  • Go to containing declaration (Ctrl-[) can be used with Shift to select the whole declaration
  • You can press Ctrl+T in Visual Studio keymap or Ctrl+N in IntelliJ IDEA keymap to quickly locate a type. Shift+Ctrl+T (Shift+Ctrl+N) for locating files
  • When locating CustomerServicesTest using Go To Type, you don't need to type the whole thing. Just use CamelCase and type cst.
  • Alt+Home in Visual Studio keymap or Ctrl+U in IntelliJ IDEA keymap takes you to the base class and Alt+End in Visual Studio keymap or Ctrl+Alt+B in IntelliJ IDEA keymap takes you to inheritors
  • Search for anything (usages, implementations, code external to scope etc.) that fetches to Find Results window. Use it then to navigate between search results (solution-wide) with Ctrl+Alt+Up/Down
  • In source code, Shift+Alt+L selects the current file in the Solution Explorer; in decompiled sources, it opens the Object Browser focused on the current type
  • To explore the stack trace, press Ctrl+E, T in the Visual Studio keymap or Ctrl+Shift+E in the IntelliJ IDEA keymap.
  • Start typing in tree views or Go To menus, and content will narrow down to matching items. CamelHumps matching works there as well
  • Use Go to File to locate specific project in the Solution Explorer - just select a .csproj file.
  • When locating a type with Ctrl+T in the Visual Studio keymap or Ctrl+N in the IntelliJ IDEA keymap, you can use wildcards. Want all ViewModels? Type *ViewModel

Transforming code

  • You can define what Context Actions you want available via ReSharper | Options | (C# or VB.NET) | Context Actions
  • Do you have multiple classes in the same file? Fix it fast. Right-click on the file in the Solution Explorer and choose Refactor | Move Types Into Matching Files
  • Rename anything, anytime, anywhere with Ctrl+R,R in Visual Studio keymap and F2 or Shift+F6 in IntelliJ IDEA keymap. You can do it even in fewer steps  - just type in a new name and hit Alt+Enter.
  • You can extract a method from a section of code using Ctrl+R,M in Visual Studio keymap or Ctrl+Alt+M in IntelliJ IDEA keymap.
  • Type in new method signature (change the number or type of parameters, change the return type) and while the signature is highlighted with a grey frame, hit Alt+Enter to apply the Change Signature refactoring.
  • Your C#/VB.NET11 iterator should not be lazy? Press Ctrl+Shift+R to invoke the Convert Iterator to Method refactoring.
  • Do you want to move to the next member in a class? Alt+Down will take you there; Alt+Up will bring you back.
  • Want to wrap some code in an if or try .. catch block? Use Ctrl+E,U in Visual Studio keymap or Ctrl+Alt+J in IntelliJ IDEA keymap to apply any of surround templates.
  • Placing your cursor on a property, you can press Alt+Enter to change it from auto-property to a property with a backing field and vice-versa.
  • Press Ctrl+R,S in Visual Studio keymap or Ctrl+F6 in IntelliJ IDEA keymap to change the signature of a method and see a preview before applying it. ReSharper will do the rest!

Generating code

  • You can add copyright header to all files via ReSharper | Options | File header text and then run Code clean-up for the whole solution
  • Alt+Ins in the Solution Explorer can create files from your File Templates .. and folders too.
  • Type class and hit TAB. Want it public instead of internal by default? Change it via live templates.
  • You can bind any command from generate popup menu to its own shortcut. Go to Tools | Options | Environment | Keyboard and look for commands starting with ReSharper_Generate.
  • Create event subscriptions in XAML/ASP.NET WebForms/VB.NET using Alt+Ins and choosing Generate event subscriptions
  • If you place your caret on a parameter in the constructor and hit Alt+Enter, ReSharper will create a field and initialize it for you.
  • Type foreach and hit TAB. ReSharper will start a live template for smart loop generation with type and name suggestions.
  • Generate data class in seconds using Generate feature (Alt-Insert).
  • Declaring a parameter in a constructor? Hit Alt+Enter to have ReSharper automatically create a field for it and initialize it.

Cleaning code

  • Think your code needs a good wash? Use Ctrl+E,C in the Visual Studio keymap or Ctrl+Alt+F in the IntelliJ IDEA keymap and run the Full Cleanup profile.

Localizing code

  • To find all localizable strings in your solution, set Localizable=Yes and Localizable Inspection=Pessimistic for the relevant projects, then find any such sting, which be highlighted with curly underline. Press Alt+Enter on it and choose Options for Inspection | Find all 'Element is Localizable' issues.

Unit testing

  • Use Ctrl+U, L in the Visual Studio keymap or Ctrl+T,L in the IntelliJ IDEA keymap to run all unit tests in the solution.
  • Want to run some particular tests? Select them in editor, right-click and choose Run Unit Tests.
  • Bind ReSharper_UnitTest_ContextRun command to a shortcut and run any test with a single key combo.
  • Start typing in the Unit Test Explorer and filter your tests by name.
  • Filter to failed tests while running them in the Unit Test Sessions window to see them pleasantly disappearing as they pass.

ASP.NET and ASP.NET MVC

  • In ASP.NET MVC applications, type return View(" and press Ctrl+Space. IntelliSense will list all available views
  • ASP.NET MVC Devs: type rta and press TAB. Fill in Controller, then Account. Now it should be in correct order with IntelliSense! 
  • Want to check for missing Views in ASP.NET MVC? Turn on solution-wide analysis. View("Login") will show as red if the Login.aspx not there
  • You can use the Go To File Member in ASPX/Config files also. Press Alt+{}  in Visual Studio keymap or Ctrl+F12 in IntelliJ IDEA keymap and look it up!
  • In ASPX pages, navigate to related files (CSS, JavaScipt, User Controls, etc.) with Ctrl+Alt+F7 in Visual Studio keymap or Ctrl+Shift+Alt+G in ntelliJ IDEA keymap

Help and support

  • You can browse ReSharper help locally by choosing ReSharper | Help | Local Help
  • ReSharper support team is always there to help you. Use the ReSharper support web site to explore FAQ and knowledge base, or submit your support inquiry.
  • If you want a new feature to be implemented in ReSharper, feel free to post a feature request in ReSharper issue tracker.
  • No labels