Is there a way of extracting a selection into a partial or another view either in VS 2013 Editor or Resharper? - visual-studio

Is there a way of selecting HTML or razor code in the VS Editor and extract it into a separate view file?
Visual Studio 2013 already has a similar feature in WebForms where code selection can be extracted into a UserControl. Also, RubyMine, Resharper's sister product, has a "Extract Partial View" feature that extracts code into a separate view file.
I'd wager that such a feature exists in either product, but I haven't been able to find it. Does it exist?

https://youtrack.jetbrains.com/issue/RSRP-263354
Doesn't look like it will be possible any time soon unfortunately

Related

Is there a feature in VIsual Studio or Resharper that can extract XAML into a separate file?

In ASP.NET Forms and MVC, you can select a block of code and extract it into a separate user control or file using Resharper and possibly Visual Studio. I cannot find such a feature for XAML. Does it exist in either Resharper or Visual Studio? If so, how do you perform this action?
I think you are looking for this:
https://www.jetbrains.com/help/resharper/ReSharper_by_Language__XAML__Refactorings.html
Resharper allows you to extract styles and resources, but you have to select the XAML and go to Resharper->Refactor->Extract in order to find the options, you won't see them if you use ALT+ENTER.

Register custom file type with custom UI editor in Visual Studio 2010

I found old article called LearnVSXNow and part #30 - Custom Editors in Visual Studio. There is sample project The Blog Item Editor which shows how to make custom file type assigned with custom UI editor for this file type extension (.blit)
This sample uses project VSXtra, which is written for Visual Studio 2008.
Can someone point me to some tutorial, how-to, or something how to do the same for Visual Studio 2010 ? My goal is to register custom file type extension (e.g. *.myext1) within visual studio 2010, and assign my own custom UI designer (WinForms, derived from UserControl) to handle editing content of such file visually.
I found some samples, but each of that shows only changes on code text editor (highlight some words, etc). But i want to show my own toolwindow with my usercontrol within it.
PS: Part of creating custom toolwindow with my own usercontrol within it is not problem, i use VSPackage Builder Project Template to build and register it within visx. My problem is how to register custom file type to use this custom toolwindow to edit file.
While the core text editor changed significantly (nearly a total re-write, designed around MEF) in Visual Studio 2010, the general infrastructure for registering and supplying custom editors/designers did not change.
The 'Creating Custom Text Editors and Designers' page on MSDN is a good place to start. You should also be able to go through the VSPackage wizard and choose "Custom Editor" to get a basic editor in place. It will give you a simple RTF editor.
You can also check out these samples on the MSDN Code Gallery for more ideas and inspiration:
Editor with Toolbox Support
Designer View Over XML Editor
It is usually recommended that editors reside in a document window (as opposed to a tool window). This is the paradigm that nearly all the built-in editors/designers use in Visual Studio, and it's what users expect when opening something from Solution Explorer. Editing things in a ToolWindow can feel a bit unnatural.
My understanding is that VSXtra provides some additional helper/base classes (beyond what Microsoft supports) to make various tasks (like writing a custom editor/designer) simpler. It is by no means required to create a custom editor though.

Shortcuts for web controls and HTML snippets in Visual Studio

Consider the feature in Visual Studio 2010 for snippets in the HTML Source view of a web page.
type a control name in plaintext with no markup or brackets!
... e.g. hyperlink.
Then hit Tab
Your web control has been auto-completed for you. It's up to you to fill in the other details that you need.
This works for form as well:
<form action="default.aspx" method="post">
</form>
This looks like a real time saver. This is supported in WebForms and ASP.NET MVC projects.
What other snippets are available in Visual Studio 2010 in the Source view of a page?
For the authoritative list of snippets, check out the VS2010 installation folders where the snippets are stored:
C:\Program Files\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033
There is one folder for ASP.NET and one for plain HTML snippets.
Also, if you use jQuery a lot, there is a set of jQuery snippets that you can add to Visual Studio as well.
Here are a ton (100's) of the short cuts in Visual Studio right from MSDN:
http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx
The one thing that has been around forever but a lot of people forget about is block selection done by holding down the ALT key and use the mouse to select a block of text. Great when you want to copy/cut/delete a bunch of code that is lined up but you don't want the whole line.
Yeah, this is a really cool new set of snippets in VS2010. Here are the articles I used to learn it:
Walkthrough: Using HTML
Snippets
Using HTML Code Snippets in Visual
Studio 2010

HTML Editor in Visual Studio 2008: how to break attributes to separate lines?

In Visual Studio 2008, I've used a nice feature in its XAML editor which breaks a line so that a control's attributes are automatically positioned on new lines: one attribute per line.
Is there a way to do the same for the HTML editor?
Thank you.
Oded, thank you very much! You gave me an idea on how to apply "one attribute per line" formatting to an ASP.NET document:
In Visual Studio 2008, right-click on the .aspx file in the Solution Explorer.
Select "Open With..".
Select "XML Editor". [Assuming that the XML Editor has been properly configured in Tools->Options prior to doing this.]
Edit -> Advanced -> Format Document.
This reformats the document so that each attribute is positioned in its own line, and all of them are nicely indented.
Of course, if I later reopen the same file in Web Forms Designer and format it again, it goes back to what it looked like before.
But for my purposes (easily finding the required attributes in a large file), this temporary solution is quite sufficient.
Once again, thank you very much!
Best regards,
Dmitriy

How do I get triple click to work in Visual Studio's Text Editor

Go into Notepad, Internet Explorer or most other applications that display or edit text. Triple click on some text. Windows will select the entire paragraph under the cursor.
This doesn't work in Visual Studio 2005.
How do I get triple click support in the Visual Studio text editor?
do VS 2008 or VS 2010 solve this?
Is there a macro, setting or plugin that will solve this?
I wrote an extension for this for Visual Studio 2010 that you can download from the VS Gallery or directly from the extension manager in Visual Studio, by searching for "triple click" or my name.
You can also read the blog post I wrote about it and check out the source, on github.
I haven't used it, but CodeProject has an article on SmartHelp 3.04 which mentions that you can triple click to select a whole line.
Also, from Craig Shoemaker's blog.
About VS 2010.
Further enhancements include the
ability to triple-click an expansive
element like a table and the editor
selects the entire table’s markup.
Want to surround that table with some
additional markup? Just start typing
with the table selected and your
markup is inserted around the selected
code.

Resources