Alt+Enter, the shortcut for everything
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!
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!
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.
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#.
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
foreach and choose Convert to LINQ-expression.
Many people prefer things the other way around, so do try the Convert LINQ to code action when it’s available!
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.
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.
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 Blog updates
Thanks, we've got you!
Eager, Lazy and Explicit Loading with Entity Framework Core
Entity Framework Core (EF Core) supports a number of ways to load related data. There’s eager loading, lazy loading, and explicit loading. Each of these approaches have their own advantages and drawbacks. In this post, let’s have a quick look at each of these ways to load data for navigational prope…
.NET Annotated Monthly | September 2023
Did you know? The original usage of the term “computer” referred to people (mostly women), not machines. It’s possible that one day the word “programmer” could morph into meaning “AI”, and no longer refers to a person. .NET news Visual Studio for Mac Retirement Announcement 🚮…
ReSharper 2023.3 Roadmap
The next Early Access Program (EAP) for ReSharper version 2023.3 is right around the corner, so it’s high time to let you know what we’ll be working on in the coming months. This roadmap is just a preliminary plan and may be adjusted depending on our priorities and resources as well as changes in…
Rider 2023.3 Roadmap
As we gear up for the beginning of the Early Access Program (EAP) for Rider 2023.3, we wanted to take a moment to share our plans for this upcoming release. These plans are subject to change, and some features and improvements may need to be pushed to a future version. Additionally…