Visual Studio comment and uncomment with a single simple keyboard shortcut - visual-studio

I want to know if it is possible to comment and uncomment text blocks in visual studio with a single command. I'm used to just press Ctrl + / to (un)comment text blocks because I've been using Intellij.
But in visual studio you have to press Ctrl + k + c to comment code out and Ctrl + k + u to uncomment.
Is there any way to uncomment / comment your code in visual studio with a single command just like in intellij?

You can actually follow this path Tools -> Options -> Environment -> Keyboard and change the drop-down selection on your top right to Visual Studio Code. This will allow you to use the Visual Studio Code keyboard bindings such as CTRL+/ to comment/uncomment.

Actually yes, there is a way.
Tools -> Options -> Environment -> Keyboard -> Edit.ToggleLineComment
With this you can comment / uncomment a single or even multiple lines with a single shortcut.

Related

How to replicate SublimeText ctrl+D in Visual Studio

I am used to work with Sublime text and trying to switch for Visual Studio for bigger projects, one of the feature of sublime that I absolutely love is its multiple select feature. You can hit ctrl + d multiple times to select next instance of the same word and then rewrite them all at once. Is there anything like this in Visual studio? I tryed to find it, but with no success.
Btw I am using Visual Studio 2015.
Visual studio 2017-19
The default shortcut is Alt+Shift+.
But if you want to add Ctrl+D
Go to the menu Tools > Options then select the Keyboard tab on the left
At the top you'll find an option to add extra keybindings, select Visual Studio Code. Save and That's it!
This works because Visual Studio Code has Ctrl+D, and other shortcuts similar to SublimeText
Alternatively you can manually add shortcuts
In the image, you can find any command to customize in the middle section.
The particular command you are interested is the one selected Edit.InsertNextMatchingCaret
Ctr R, R, this is used to replace the name of the varibals, depronto can serve it.
and you are encouraged here are all the shortcuts of vs2015 http://visualstudioshortcuts.com/2015/
Goto Tools / Options / Keyboard
Search for duplicate
Choose Edit.Duplicate
Remove the assignement for the current shortcut
Assign the shortcut you want
Ctrl + Shift + L seems to work.
Use Alt +leftClick and ctrl+F2 . For more reference you can go Official Website [link]https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference
I decided to use this Visual Studio Extension:
https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.SublimeVS

Ctrl+K was pressed. Waiting for second key of chord

I'm using Visual Studio 2013 Ultimate and when I select a code to be comment I press Ctrl+K but it show me this once I pressed Ctrl+K was pressed. Waiting for second key of chord... any idea how to fix it?
There is a command Ctrl K+C to comment any line, and Ctrl K+U to uncomment.
You can see what the keyboard binding is under Edit > Advanced > Comment Selection (2010):
And 2013:
Additionally, you find keyboard bindings under Tools > Options > Environment > Keyboard. Here if you search for "Comment", you can find the Edit.CommentSelection (and Edit.UncommentSelection) which you can assign whichever shortcut you prefer.
You can look after and manage your shortcuts in Tools / Options, Environment / Keyboard.
You should see a dropdown menu where all shortcuts are listed.
There you can change your existing shortcuts or reset them to the default.
The default shortcut for me (Visual Studio 2015 Community Edition) to comment was Ctrl K + C and to uncomment Ctrl K + U.

Duplicate line short cut does not work in VS 2013

I have Visual Studio 2013 and Resharper installed.
Until recently when I pressed Ctrl D, Ctrl D I was able to duplicate the line I was on.
Now it does not work.
How do I go about fixing this?
Go to Tools -> Options -> Keyboard. Then select command ReSharper.ReSharper_DuplicateText from list (autocomplete works).You may press Ctrl+D and assign it to selected command. It's possible to set scope (Global etc.). By default I have Text Editor and XAML scopes.

What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio?

In Eclipse, selecting a line and pressing Alt + ↑/↓ will move the line up and down, a quick way to avoid copy&paste.
Is there an equivalent in Visual Studio?
In Visual Studio 2013 and later, this functionality is built in. ALT + UP/DOWN will move a line up or down.
If you need this functionality in VS2012 (works with VS2010 too), take a look at the MoveLine Visual Studio Extension or the Productivity Power Tools suite.
ReSharper's Ctrl + Shift + Alt + ↑/↓/←/→ is even more powerful - when on the beginning of the line, it will move the entire line, but can also be used to move entire methods, change the order of parameters, etc.
For me in Visual Studio 2019 it comes default closed.
For open it:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesUp, click "Press shortcut keys" input and press Alt + Up (or whatever you want for it). And the other one is Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down (or whatever you want for it).
This is now working out of the box with Visual Studio 2013, same way as in Eclipse.
For Visual Studio 2013:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down. You also have to select the scope of the shortcut to be within "Text Editor".
In Visual Studio 2013 and later, you can move lines up and down using Alt + ↑ / Alt + ↓. Unfortunately this will not adjust the indentation if you move between blocks, as of today only ReSharper (and all other IDE's by Jetbrains including Rider) can help you with that.
To move entire blocks of code around you can move the cursor to its head and press Ctrl + m twice fast to collapse it, and then use the command above to move it around.
Here is a neat reference to all default keyboard shortcuts in different versions of Visual Studio.
With the VSCommands extension, you have exactly that keyboard shortcut. And, by the way, a Stack OVerflow notification toolbar :)

Why does the Visual Studio editor show dots in blank spaces?

I have a strange bug in the Visual Studio text editor.
All my blank spaces are replaced by a "."
public class Person
{
int age;
}
looks like this
public..class..Person..........................
{..................
..int age;...................
}.....................
I reset the settings to default. Didn't work.
I also re-installed VS2008. Still didn't work.
What's the error?
Visual Studio is configured to show whitespace.
Press Ctrl+R, Ctrl+W.
If you are using C# keyboard mappings: (thanks Simeon)
Press Ctrl+E, S.
If you want to use the menu: (thanks angularsen)
Edit > Advanced > View White Space
Looks like you have the view white space option enabled. Go to Edit -> Advanced -> and uncheck "View Whitespace"
In Visual Studio 2012
Go to
Edit -> Advanced -> View White Spaces
Or
Press Ctrl+R, Ctrl+W
~ FOR VISUAL STUDIO 6 ~
use: ctrl+shift+8
to toggle on/off.
(or manualy go to: Edit> Advance > "View Whitespaces")
goodluck!
Works also for Visual Studio 2008, when
Tools/Options/Environment/Keyboard/Mapping Scheme: Visual C++ 6
is selected.
Please press below buttons in combination of
Ctrl + R,W
I had the same problem and resolved by pressing Ctrl + R , Ctrl + W.
In Visual Studio vesrion 1.34.0 View -> Toggle Render Whitespace
Press ctrl + E followed by S key to remove the lines in Visual Studio 10
go to File -> Preferences -> Settings, this will open two panels side by side, the left one is default setting and the right one is user setting, you can add your setting on right panel, for this you can add "editor.renderWhitespace": "all".
In visual studio 2015, goto->view->formatting marks, unselect show
In Visual Studio 2019, this can also be configured in Tools -> Options -> General -> View whitespace

Resources