Полезна информация за C#: "Selection shortcuts for lazy coders"


9

How do I select one word at a time?

You can select text using the keyboard as well as the mouse. If you put the cursor anywhere in the code and hold down the <SHIFT> key and then use the right or left arrow key, you can make a selection one letter at a time.

image

If you hold down the <SHIFT> and <CTRL> keys then using the arrow keys will select one word at a time.

selecting one word at a time

How do I select to end of line?

If you hold down the <SHIFT> key and then press the <END> key you select from the cursor location to the end of the line

select to end of line

How do I select an entire line of code as quickly as possible?

I discovered this trick by accident, and fell in love with it. If you want to select an entire line of code, all you need to do is put the cursor anywhere on the line, do not make any selection at all and then do the desired command (Cut, copy, or paste). When there is no text selected, cut, copy and paste default to selecting the entire line. Try it!

How do I select multiple lines of code starting from a particular column?

Have you ever tried to select code on multiple lines? If you just start in the middle of a line of code and select multiple lines of code you end up with a selection like this:

select multiple lines of code

Now try holding down the <ALT> key as you make a multiple line selection. This works if you are selecting with the keyboard or the mouse.

box select

When you use the <ALT> key you get something called a box select. This can be useful if you are trying to copy a list of variable names, comments, or namespaces without the entire line of code.

BONUS TIPS!

Okay if you actually scrolled down this far, here are the two bonus tips I promised.

Not only can you select code over multiple lines with the <ALT> key, you can actually edit code on multiple lines as well. Let’s say you have a list of variables declared as private and you decide they need to be public. Use the <ALT> key to do a multiple line selection of the keyword private across all the declarations.

box edit

Now start typing the word public, as you type it will replace the selected text on each line with the new text you type

box editing

Last but not least, you can actually insert text on multiple lines of code using the box select technique as well. Let’s say I wanted to add some similar comment text after each variable declaration above. Use the <ALT> key to do a multiple line selection, but make your selection at the position in the line where you want to add the comments.

box insert

Now start typing the text you want to insert, as you type it will be added to all the lines.

box insert

If you like that multi-edit feature, you may also want to check out this neat little add-on for Visual Studio called MultiEdit Extension for Visual Studio. After you install the extension, if you hold down <ALT> while mouseclicking in the editor it will add multiple selection points wherever you clicked. Then you just type and your text is added to all the selected positions. Scott Hanselman wrote a blog post about ithere. Thanks Andrew for pointing out this neat little extension.

Източник: https://blogs.msdn.microsoft.com/cdnstudents/2013/10/07/visual-studio-tips-selection-shortcuts-for-lazy-coders/




Отговори



1
Към този, който е сложил минус...не че нещо, но момчето е отделило от личното си време за да синтезира информация, която всъщност е полезна, споделил я е с всички за да не се налага и ние да отделяме от времето си за това. Интересно ми е каква точно е била логиката ти за да оцениш този пост като не полезен. Shame on you!

от milislavski (886 точки)


3
Нещо, което аз лично много ползвам, и не виждам тук е с натиснат Alt и след това стрелка на горе или на долу. Това премества всичко което е селектирано нагоре или надолу. Много ми е удобно когато трябва да си подреждам кода, без да се налага да кътвам и пействам (изрязвам и поставям или както там се казва :).

от wnvko (3123 точки)


0
ИИ това много яко...

от ivan.mihov1 (4988 точки)