📜 ⬆️ ⬇️

We work with the Control button in Visual Studio + Resharper

Introduction

There are so many articles on how to speed up your work. They write about "programming at the speed of thought." However, I want to share with you one trick that will allow you to work even faster. This will require Visual Studio 20xx + Resharper.

When working in the studio, I conditionally share two modes of operation:
')

In a bunch of studio and resurper, the Control button for text editing I use for such combinations:


Note that all these combinations can be done with one left hand, and you do not need to remove your right hand from the mouse. By default, Control + click works in the same way as Control + B. If you remove the transition to Control + click in the Resharper settings, we will get the whole word to stand out for this combination, which is very very convenient. What advantages gives us the selection of the word Control + click consider the examples.

Duplication of code with subsequent changes:

Suppose you have this code:



Pay attention to the BsonKnownTypes attribute, which is needed for the mongo driver to store documents of different classes in the collection. Suppose you want to create another class in this hierarchy. Using the Control button this can be done very quickly. Highlight the code from the last closing bracket of the Cat class to the last closing bracket of the AnimalBase class:



Press Control + D:



Without removing your finger from the right Control, make 2 clicks on the bottom word Cat; The first click removes the selection, the second selects the entire word Cat. You can double click on the word Cat: more convenient when the left hand is not on the Control button, but, for example, scratches your nose:



Transfer your hands to the keyboard and type Dog:



Of course, it was possible to make an heir using a resharper, but I wanted to show how to select text between curly brackets and the Control + D combination, which allows you to immediately write code with indents. Plus, you already get the Name property in the Dog class, which you can quickly modify to another property.

Now you need to teach the Mongo driver to understand the new heir, to do this, click on any place in the line with the BsonKnownTypes attribute and press Control + D:



Without removing your finger with Control, click on the word Dog and press C:



Then (still holding Control), click on the Cat word in the BsonKnownTypes attribute and immediately press V:



Done!

The combination of click + V with the control pressed allows you to replace the word very quickly. Please note that here “click + V” does not mean that you press them at the same time; first you click, then press V, but since this is done with different hands, it can be done very, very quickly, almost simultaneously. You take aim, click + V, and the word is replaced. And since the word is highlighted entirely, you do not need to try especially when aiming, you do not need to get to a certain point between the letters, to accurately set the cursor, you just need to get to the word. Believe me, this allows you to replace words in the text very quickly, and you will see this in the following example.

Replacing Count with Length

Let's say you solve some puzzle with projecteuler.net and write this code:



Thinking a little over the task, you decided that instead of an array, you had better use the sheet:



Oh no, the sheet doesn't have the Length property to use the sheet, now you need to go over the whole code and replace Length with Count. To do this, double click on the first Length, and write Count:



Now move your right hand to the mouse, and with your left hand, press and hold Control. Then, click on the word Count written by you and press C. The word Count is on your clipboard, and you can use a combination of a click + V. Aim at one of the remaining Lengths and click on a click + V, aim at the second and again click + V. Everything! Replacing two Lengths will take you less than a second, and there will be no problems replacing at least 10.



Okay, but now you may not like the name arr, it does not fit its class. You can rename the studio or resharper, but for a workout, I advise you to use the Control key again, and you will see how fast it is. The order of operations: highlight the word arr, write a list instead, then press Control and: click + C, click + V, click + V, click + V, click + V, ... If you miss and accidentally replace another word - it does not matter. Without pressing Control, you can press Z and cancel the operation.

Epilogue

To replace words other than Contorl + click, there is another way - select the necessary block using Control + W and use the replacement Control + H. With this combination, you don’t need to use the mouse at all. This method is great, but at least for me, harder than Control + click. If you click "replace in the whole text", then you will have to think, and whether it would not be too risky, whether something is replaced. If you replace one occurrence, you will have to analyze the context of each occurrence. Not that this was a big problem, but I still often choose Control + click. And I use Control + H when I really need to change many occurrences.

The Control key in combination with clicks, buttons C, V, X, W, and others allows you to raise the speed of working with text to a new level. With enough training, this combination can work simply and naturally. If you want to copy a few words, then you can hold down Control, click the left mouse button, and press the cursor over the words. All these combinations together make the Control button really a control button. You do not need to carefully aim to get into a changeable place. You work with the clipboard, easily roll back operations if something went wrong. The renaming tools built into the studio and resharper are excellent, but they do not always understand all the correlations between words. This technique is not complicated, but allow you to work on the text even faster. The faster you work with the text, the easier it is to enter the stream state, you are not distracted by trifles, and express your thoughts in code instantly. I think this article is also useful for experienced developers who know all combinations of resharper and studio.

Source: https://habr.com/ru/post/245095/


All Articles