8

In Resharper when I go back to edit some existing code.. eg. wanting to insert a String.Format into this code:

<td>
    <%= Html.Encode(item.Address) %>
</td>

I move the cursor to before 'item' and type in 'String.F', getting Resharper's intellisense completion list that includes the 'Format' method.

However if I press TAB then it replaces 'item' with '.Format()'

Is there a way to use completing without replacing the existing text?

1
  • Resharper is great, it almost turns Visual Studio into IntelliJ ;-) Commented Sep 14, 2010 at 7:23

5 Answers 5

10

Stumbled upon using Enter instead of TAB to choose from the completion list. That does exactly what I want. It surrounds (in this case) 'item.Address' with the String.Format( .. ).

Sign up to request clarification or add additional context in comments.

Comments

9

There are two techniques you can use.

The first is to use the Enter key, the second is to pop a space between where you are going to start typing and the next bit of code, which will prevent the next bit of code from being overwritten.

1 Comment

Down-side of the space technique is that you then have to hit the back-arrow.
6

There is an actual setting now to disable this (annoying) behavior.

Go to the Options dialog (Menu -> Resharper -> Options). In this Options dialog go to Environment -> IntelliSense -> Completion Characters.

Here you can set the Tab behavior to Insert instead of Replace.

Screenshot of Options

Resharper documentation about Completing Characters

This is an addition to the answer in 2010, for everyone that reaches this post via populair search engines ;)

Comments

1

You could also use the String.Format surround template but you may have to map a hotkey to it for easier access.

1 Comment

You are right, though I was really thinking of the more general case - String.Format was just a good example.
0

The keyboard command you want to use is called: Resharper_ForceCompleteItem. So if you go into Visual Studio's Tools > Options > Environment > Keyboard you could assign a keyboard shortcut there. Not sure if it would be possible to use Tab, though.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.