Sorry for the silly question, but i'm trying to move my code right but doing it line by line.
Lets say my code is
if x==0:
print a
else:
if x==3:
and lets say i want to add new "if" in the begining of the code i need to take all my code right
so the new code will look like:
if y==3:
print y
else:
if x==0:
print a
else:
if x==3:
as for today i'm pressing "space" several time on each line to set it in the right place
I know that "ALT" and arrow take it up\down but coudnt fine the left right if there is something like that
thanks
Either move it line-by-line with TAB, or select several lines and use TAB. You can move them in the other direction with Shift+TAB. As already suggested you can also use Ctrl+K, Ctrl+F to auto-format.
In the visual studio settings you can decide whether the spacing consist of tab symbols or actual blank spaces and the number. Keep this in mind, as some file types don't like one or the other.
you can use Shift+tab to move the whole code 1 tab space
Related
This seems like something I would have found hundreds of topics on. Yet I didn't find a single one. I wonder if no one cares or if I just overlooked something obvious.
In Visual Studio when you select a column and want to select the word your cursor is at in each line, when you do CtrlShift+(ARROW KEY), then it doesn't select by word as it SHOULD, but instead it selects a square.
BAD BEHAVIOUR (which VS has):
GOOD BEHAVIOUR (which would be expected, and is in every other IDE):
The Visual Studio ALT select is rendered useless in half the cases, actually in every case where you don't have the "coordinates" precisely the same on every line.
EDIT
I seem to have to explain why the VS behavior is bad, people apparently consider it ok. So the problem is that when you column select in VS, and you have it exactly like in the example, or even without tabs, you'd copy some =, though they won't be everywhere.
If you select a column like VS Code or JetBrains has it, you'll just copy WHAT IS NEEDED and that OBVIOUSLY being just the words in the column.
I have a solution for you, but you may not like it. It's using the new Multi-Caret Support in Visual Studio 2017.
Here is my example code where I want to copy only the property names (sorry for lack of inline images):
Multi-Caret Code Example
Using Ctrl + Alt + Click to click and add a caret to the end of each word. (If you screw up and click somewhere you didn't mean, like I do many times, then reclick to remove that caret and click on the correct spot.)
Multi-Caret End of Line
Now hold Ctrl + Shift and hit the ← Left Arrow. This will select to the beginning of the current word on each line.
Multi-Caret Word Selected
Copy/paste as you wish
I have a class with many lines in it. I can hit a breakpoint and then drag the yellow break arrow back to a specific line but it can be difficult to do this when the line of code you need is hundreds of lines away.
Is there a way to accomplish this by typing in the line number you'd like to take the arrow to?
Also, how do you jump to a line in a different class file?
Thanks in advance.
Right-click the desired line and select "Set next statement". Or you can use the default keyboard shortcut Ctrl+Shift+F10.
This feature can only be used to set the statement to another line in the same method/function, so you won't be able to skip to a different file.
You don't have to drag the yellow line just go to the line right click and select set next statement
My question today is, when selecting multiple lines of code and not completely selecting the full line for all the lines selected, how can I (or is there any keyboard shortcut for) block select all the lines that I have already selected, so that I have not just some lines fully selected and some not fully selected, but all the lines are fully selected from the home of the top line selected, to the end of the last line selected?
Note: The bold text in the segment above is what I am mainly trying to ask.
Thanks to anybody that is able to provide me with any helpful information!
From your question it looks like you want to select a block and not the complete line.
Hold the alt key and use the mouse to select your block.
You can use Alt + Shift + Arrow keys..
Its called Box Selection and was introduced in VS2010.
learn more about it here
All right, this is stupid, but I have no clue how people deal with this and I'm hoping I'm missing something...
When I write something like this:
if (n == 0)
...The closing parenthesis gets added as soon as I type the opening one. The only way I know of to get out of them now is to reach over and tap the End key or something, which kind of ... Damages my shui, you know? And yet apparently they thought this feature was a cool idea, so...
What do you normally do to tell the IDE that you're done with this bit and you're ready to move on to the next? Same question applies to automatic quotes and stuff in the XAML editor, I guess.
Just keep typing - if you type your own ) when the cursor is just before the automatic one, it should not create another ), but just move the cursor over it.
(Disclaimer: I'm not certain this works on a vanilla Visual Studio - I have a bunch of extensions installed)
You can press Ctrl + Shift + Enter to open a new line below the current one without moving the cursor to the end of the line.
To add to this, Tab is another option and I find it easier:
In your example, type the logic, press Tab to skip passed the end bracket.
If you are inside auto quotes, type your text, then press Tab twice.
Like the other answer, it only applies when first being typed, so if you go back to edit something, you are left using the End and Arrow keys.
In Visual Studio 2015 with Productivity Power Tools installed (probably works earlier as well), when being inside an auto-complete block (quotes or braces):
end goes to line end ( typically slow to type/find)
"/) typing same key as auto-complete already inserted will simply replace the auto-inserted character
tab jumps over end of auto-complete (e. g. braces or quotes)
shift+enter adds ; at end of line, goes to new line (often what you want)
ctrl+shift+enter goes to new line
There is a short key in VS - "Edit.LineEnd" - pressing "End" you get to the end of the current line. I've re-assigned it (for me the best variant was "Alt-Enter") and use it to get outside of parentheses and quotes.
Hit the enter key when you are done typing.
When Visual Studio (2005) has Options -> Text Editor -> C/C++ -> Tabs -> Indenting set to Smart it will automatically indent code blocks and line up squiggly brackets, {}, as expected. However, if you hit enter inside a code block, move the cursor to another line, and then move it back, the inserted tabs are gone and the cursor is positioned all the way to the left. Is there a way to set Visual Studio to keep these tabs?
As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.
Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that you've described).
This is an annoyance to myself as well. Anytime the code is reformatted the blank lines are de-tabbed.
You might look at this: http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7 it's not exactly a solution but a step in the right direction