Microsoft Developer Network >
Forums Home
>
Microsoft Visual Studio 2010 Beta 2 Forums
>
Visual Studio Editor
>
Box Selection in Visual Studio 2010
Box Selection in Visual Studio 2010
- Hey, not a question here...I just wanted to say kudos on the box selection bits.
I saw the intro video earlier in the year, but it didn't show off all the cool things that are going on there.
I really like the way you can "walk the box", if you will, by using shift+cursor keys to change the shape of the editing area. This is super handy.
I'd be interested to know if there's a way to tie into the box selection from a plug-in standpoint. While I think you guys have made this a better feature, I'd like to be able to extend it as there are possibilites to better the extraction and insertion stories. And you know what I'm talking about...I saw the awkwardness in removing those semi-colons in the video ;o)
Short of that, I did figure out a meta-way to do the semi-colon removal without having to write a plug-in, along with a few other notes: http://theycallmemrjames.blogspot.com/2009/10/badass-box-selection.html
Thanks for this, and cheers!
All Replies
- Depending on your scenario, the answer is very likely "yes" or "yes, though it may be a little complicated". I'll try covering a few ways in which extensions may interact with box selection, and then you can let me know if this covers your scenario:
First, the selection itself exposes various properties and methods for getting and modifying the selection and selection mode (ITextSelection, http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.text.editor.itextselection_members(VS.100).aspx). Any component can do what they please with that.
In terms of interaction with certain commands, your extension can capture and respond to events before/instead of the editor doing so. For example, your extension could listen for the backspace command and handle it specially when there is a) an empty box selection and b) the selection spans are all either at the end of the line or in virtual space, preventing the editor from performing its normal backspace operation. The same thing goes for handling Copy when a box selection is made, which is what it sounds like you are getting at from your blog post (on copy, bring up some UI about preserving space, etc.). However, this would be a bit less straightforward, as you have to make sure to get the clipboard situated correctly (in essence, the box clipboard format is an endline separated list of lines and a special clipboard tag to annotate that it should be a box). It is, however, doable.
(You can see a skeleton of what a command filter looks like here: http://github.com/NoahRic/EditorItemTemplates/blob/master/CommandFilter.cs)
If you give us some more information about what you are trying to do specifically, then I may be able to point you further in the right direction.
Thanks!
-Noah- Proposed As Answer byBrittany BehrensMSFT, ModeratorFriday, November 20, 2009 10:11 PM

