Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper completion without overwriting existing code

Tags:

resharper

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?

like image 667
David Gardiner Avatar asked Sep 14 '10 06:09

David Gardiner


4 Answers

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( .. ).

like image 83
David Gardiner Avatar answered Oct 21 '22 13:10

David Gardiner


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.

like image 31
Fenton Avatar answered Oct 21 '22 14:10

Fenton


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 ;)

like image 27
Patrick van Ek Avatar answered Oct 21 '22 13:10

Patrick van Ek


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

like image 1
CyberDude Avatar answered Oct 21 '22 13:10

CyberDude