Alt+Enter, the shortcut for everything

Rachel Appel

As developers, we love tools. But often, too much tooling gets in the way when trying to develop applications quickly. Have you ever been ripping through code when you want to refactor or do a common task, but just can’t find the command for it because there are too many distractions? It’s very frustrating! Let’s take a look at how ReSharper brings back simplicity when using an IDE, with its famous Context Actions – or Alt+Enter – the small but mighty problem-solving shortcut.

And keep in mind: Rider builds on top of ReSharper, so these features work there, too!

Enter, Alt+Enter!

Context Actions become available automatically while you’re programming. ReSharper continuously monitors programming activity, and reveals Context Actions when you use the Alt+Enter keyboard shortcut.

These actions are, well, contextual, based on the code at the current position of the caret in the editor. This means that if there are quick-fixes or optimizations that can be made, ReSharper suggests them. Whenever you see a yellow or red light bulb or a hammer icon in the gutter, press Alt+Enter and ReSharper shows context-related suggestions to you.

Alt+Enter is your not-so-secret superpower! (because we just blogged about it). You don’t even need to place the cursor on a line of code. Put that cursor anywhere, press Alt+Enter, then start typing, and watch the magic happen! The IDE shows a list of all the things that even remotely match your entry – from actions, to configuration and settings, and more. Put on your superhero’s cape, because there’s nothing you can’t do with Alt+Enter!

Use Alt+Enter for everything

What’s in a name?

A famous author once said, “A rose by any other name, has been rename-refactored.” Or something like that. Anyway, renaming is something developers do several times an hour. So it makes sense that ReSharper has a first class way to rename, and that’s with a Context Action. Just rename the language construct in question, press Alt+Enter, and ReSharper renames every reference to it.

Use Alt+Enter to rename refactor

Express yourself with switch expressions

Context actions can help you upgrade to newer language features! One nice upgrade is converting from traditional switch statements to switch expressions in C#.

Make a switch expression

LINQ it up!

Loops are a traditional way of repeating a task with code. But they’re not always necessary. There are times when the code can be more expressive and concise with a LINQ expression instead. So go ahead and let Rider or ReSharper update that old dusty loop to a new shiny LINQ expression. Use Alt+Enter on a for or foreach and choose Convert to LINQ-expression.

Use Alt+Enter to convert an IF to LINQ

Many people prefer things the other way around, so do try the Convert LINQ to code action when it’s available!

Using usings

While you’re coding, you want certain behaviors to be almost invisible so they don’t disrupt your flow. Nobody wants to have to stop what they’re doing, navigate to the top of a file and type in a using statement. That’s disruptive! So ReSharper has the Add Usings action. When you see a red lightbulb and the type is displayed in red font, press Alt+Enter.

Use Alt+Enter to import namespaces

Time to clean up

Mom would be so happy to know you’re keeping your code nice and tidy – unlike your room. Urging you to keep your code clean is good advice for writing code. The compiler might not care if your code looks sloppy, but ill-formatted code is difficult to read, and therefore challenging to maintain.

Never fear, when it comes to code clean-up, ReSharper is like the Roomba ® of IDEs. Thy automatically clean up everything just perfectly. All with Alt+Enter.

Use Alt+Enter to format code


These are just a few examples of popular quick fixes that ReSharper (and Rider) have to offer. Tune into the JetBrains .NET Blog for more quick fixes and assistance from Rider and ReSharper. Let us know your favorite magic tricks, courtesy of Alt+Enter in the comments.


Subscribe to .NET Tools updates