microsoft programming software tips

square brackets not working in visual studio and how to fix that

Have that thing where your square brackets (aka the [] thingies) don’t work any more when you want to access an indexer in Visual Studio 2010 to 2015 (or maybe even later)?
It’s your shortcut keys that are messing with your keyboard I tell ya!

Update: you can remove the shortcut by following the procedure below, but it turns out this is actually caused by the VS Productivity Power Tools add-in. If you disable the “Align assignments” feature in the plugin’s options, you’re done. The procedure below can be handy to debug other shortcut issues however, so feel free to read on anyway. ;)

So to fix this very annoying little side effect, you go to Tools > Options > Environment > Keyboard from the menu.
Now in the text field to create a new shortcut, press the combo to get your square bracket, which is Alt Gr + ^ in my case (Belgian keyboard). That should show you which command is using up your key combination as a shortcut. In my case that’s Edit.AlignAssignments.

The VS2010 keyboard options.

Then it’s just a matter of looking that command up in the list and smacking the Remove button. That’ll teach it to mess with your shortcuts dammit!

I get the impression that these changes are only saved when you close your Visual Studio instance. So if you have more than¬†1¬†open, you have to close the one where you changed the setting in last. Otherwise, you’ll have to do this again. And again. And again….

2 replies on “square brackets not working in visual studio and how to fix that”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.