This has been asked before: Why doesn't Visual Studio code formatting work properly for Razor markup?
But that question is a couple years old. And Razor formatting is still completely unacceptable. I have given up on fixing it.
Can I disable ALL Visual Studio formatting for CSHTML files? If not, can I disable all Visual Studio formatting entirely? Any 3rd party hacks I can use? There's got to be something!
I've upgraded to 2013 and the formatting is just as bad.
[EDIT]: 2015 is god-awful as well. I REALLY wish they would fix this.
[EDIT]: 2017 is god-awful as well. I REALLY wish they would fix this.
[EDIT]: 2019 is god-awful as well. I REALLY wish they would fix this. That said, Microsoft released a new formatting engine for .Net Core only.
[EDIT]: 2022 is... Well you know. If they ignore this 12 more years I may retire before seeing it fixed!
Under Tools -> Options -> Text Editor -> HTML -> Advanced
there is a key value item Paste which says "Format on paste" and has a boolean value next to it. Changing this to false has disabled formatting on paste for me in razor syntax.
I am using VS Professional 2013, Version 12.0.30110.00 Update 1
You cannot. This is built in "feature" of VS since the first .net version (visual studio 2002/2003).
There are tons of connect report about the formatting bugs, but Microsoft ignores them completly, or pushing the fix to the "next version". You can see an example Microsoft answer here.
You can post your own feedback to Microsoft Team here
The places to look:
Tools -> Options -> Web Essentials -> HTML -> Auto-format HTML on Enter
(Requires installation of Web Essentials extension)
Set to False
Tools -> Options -> Text Editor -> HTML -> Advanced -> Format on Paste
Set to False
With these settings I have no trouble in Visual Studio 2013.
I used to have to press Ctrl-Z far too often, and if you forgot untangling the mess once your code was written and tested was a huge pain. I feel Microsoft could do alot to help users configure this as well as make it more accessible.
What did the trick for me was pressing CTRL+Z after pasting, then the formatting is removed.
In my case R# ended up being the culprit, can be disabled here:
ReSharper > Options > Code Editing > Razor > Editor & Formatting
https://www.jetbrains.com/help/resharper/2016.1/Reference__Options__Languages__Razor__Editor.html
Unfortunately the only way to prevent autoformatting on paste is to comment out the location where you're going to paste some new code and after the pasting operation to remove the commenting instructions.
Search & Replace seems not to trigger auto-formatting. But pasting reformats the entire code block.
This is terrible beyond words. It makes Visual Studio IDE virtually unusable for Razor editing. One has to use an external editor for Razor files.
What's even worse, even the latest Visual Studio 2013 Update 1 crashes while editing Razor views all the time.
The fun part is, you can disable C# formatting and HTML formatting but not Razor formatting.
I've unchecked "Tools > Options > Text Editor > C# > Formatting > Automatically format on paste" and the same for HTML.
Which results in the following fun experience in cshtml files:
Paste HTML code: no format
Paste C# code: no format
Paste Razor code: format everything wrong
And since there is no option to change the Razor options, you have to live with this I guess.
My "solution": paste and ctrl-z to undo the auto format
I do not have a .Net Core project nor Blazor. So unfortunately I cannot test this. But a new formatting engine has been released by Microsoft for these languages.
https://devblogs.microsoft.com/aspnet/new-experimental-razor-editor-for-visual-studio/
Requires the latest edition of Visual Studio 2019.
I found these settings in Resharper 2019, which have improved my experience:
The below does not directly answer the posed question, but offers a potential fix that may be helpful.
In my situation, the auto formatting was only preforming exceptionally poorly for some files. This turned out to be related to the type of line feed used.
To resolve:
I enabled advanced save options
When saving the problematic files, I selected Windows (CR LF) as the line feed type
Supporting docs
After doing this, autoformat appeared to behave better
Visual Studio has a word wrap feature, but frustratingly it ignores line indents, making the text hard to read. Other text editors (Notepad++, Sublime Text) simulate the indentation of wrapped lines, making code easier to read
How can I make Visual Studio 2012 wrap lines intelligently? Smartly?
See in Notepad++, 'of beer' is wrapped appearing in line with Console
Where as in Visual Studio, 'bottles of beer' juts out into the indentation, making the code shape hard to read.
Good news: In Visual Studio 2013, word wrap properly respects indents!
However there's a number of remaining issues with it (eg. around the Home/End keys). Please vote at https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5574507-fix-behaviour-of-home-end-keys-when-word-wrap-is-e
Alas, it's not possible. Bug to the Visual Studio developers at http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3285423-wrap-lines-intelligently-simulating-indents- . Please vote for it!
This extension does what I want, but only for Visual Studio 2010 :/
http://visualstudiogallery.msdn.microsoft.com/ac95f80f-6cfd-4b67-b0fd-e9c5c8fb27de
NB. I tried hacking the extension manifest to make it install on 2012 but the behaviour went awry. The extension needs a real update
For VS2012, there is an extension
http://visualstudiogallery.msdn.microsoft.com/a5b5001e-fe7a-4c08-9cf5-96ae5892088a
It does the same thing...
I was used to use RockScroll (or MetalScroll), but when I started to use ReSharper my RockScroll start to show some bugs. Well, this is scope to another discussion https://stackoverflow.com/questions/1089493/is-rockscroll-compatible-with-resharper.
But my problem is related, because now without MetalScroll I can't highlight all occurrences, what I consider very useful in many situations.
Someone have another plugin for VS2010 or for ReSharper that do the same or better?
I think you are looking for "Highlight usages in file" This can be access via Shift+Alt+F11 or Ctrl+Shift+F7 depending if you are using VS key bindings or InteliJ bindings. Use either Ctrl+Alt+Up/Down or Ctrl+Alt+PageUp/PageDown to go to next and previous highlights.
You can also use the Ctrl+Alt+G combo to bring up a menu of what to jump to. This can be used to move the cursor to the next occurrence.
You should try Productivity Power Tools for Visual Studio 2010. There are other versions, at least one for Visual Studio 2013 and another one for Visual Studio 2015.
It plays nicely with ReSharper and has this selected text matches highlighting both in the editor and the scrollbars among many other features.
Try the visual studio extension RockMargin which highlight the occurrences on double click (like most IDEs). Works fine with VS 2015 and ReSharper.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
What are your recommended extensions for Visual Studio 2010?
(Please indicate if its free or not And also its purpose / function too)
Free:
VsCommandBudy - Extend VS with external commands where really need them (Free)
PowerCommands - useful extensions for the Visual Studio 2010 adding additional functionality to various areas of the IDE.
DevExpress CodeRush Xpress - Coding assistance, Intellisense navigation,etc.
AnkhSVN - Subversion Support for Visual Studio.
Ghost Doc - Simplify your XML Comments.
Visual Studio Color Theme Editor - make your VS2010 look pretty with themes.
VsVim - VIM emulation layer for Visual Studio.
DPack - FREE collection of Microsoft Visual Studio tools.
VSFileNav - fast searcher with wildcards + camel case searches.
Sonic file finder - fast and convenient search.
AllMargins
tangible T4 Editor plus modeling tools for VS2010 adds IntelliSense and Syntax Coloring to T4 Text Templates
Word Wrap with Auto-Indent
Indentation Matcher Extension
Structure Adornment
BlockTagger
BlockTaggerImpl
SettingsStore
SettingsStoreImpl
Source Outliner - not available on this link.
Triple Click - Makes triple click select an entire line.
ItalicComments
Go To Definition - Make ctrl+click perform a "Go To Definition" on the identifier under the cursor
Spell Checker - not available on this link.
Remove and Sort Using - Adds a context menu entry to Solution Explorer that sorts and removes using statements on every file in the solution, project, or on the individual file.
Format Document - Adds a context menu entry to Solution Explorer and the code window that executes the Edit-Advance-Format Document command on every file in the solution, project, or current code window.
Open Folder in Windows Explorer - Extends the Open Folder in Windows Explorer context menu option to the code editor and to all files in solution explorer.
Find Results Highlighter - Highlights the search text in the find results windows.
Regular Expressions Margin - A margin which exposes .Net Regular Expressions search and replace capabilities on a given code window.
VSCommands - not available on this link.
HelpViewerKeywordIndex - Visual Studio Extension for the Microsoft Help Viewer
StyleCop - StyleCop analyzes C# source code to enforce a set of best practice style and consistency rules.
Extension Analyzer - Extension Analyzer helps debug issues with VSIX Components, Visual Studio Packages, PkgDef Files and MEF Components.
CodeCompare - Code Compare is an advanced file and folder comparison tool. This programming languages oriented diff tool can be used as a Visual Studio add-in and as a standalone application.
Team Founder Server Power Tools - not available on this link
VS10x Selection Popup - not available on this link
Color Picker Completion - not available on this link
Numbered Bookmarks - Numbered Bookmarks allows users to create and recall bookmarks by using numbers. User can create 10 bookmarks (starting from 0 to 9).
Mouse Zoom - Mouse zoom at the mouse's cursor instead of at the top of the visible document. See VS options...
Visual Studio 2010 Pro Power Tools - A set of extensions to Visual Studio Professional (and above) which improves developer productivity.
JSEnhancements - provides outlining and matching braces highlighting features for Visual Studio JavaScript editor; provides fantastic #region collapsing in JS and CSS files, making long files much easier to handle;
Code Contracts Editor Extensions - Displays Code Contracts (when editing C#) in code, Intellisense, and in metadata files.
WoVS Quick Add Reference - Add missing assembly references right from the code editor
JScript Editor Extensions -
Align By
T4 Editor
Quick Open File for Visual Studio 2010 - quick opening any solution file
CleanProject - Cleans Visual Studio Solutions
PhatStudio - fast file navigation and quickly opening files
VsVim - Vim style keyboard shorcuts
Chutzpah - Open source JavaScript test runner
I Hate #Regions - makes expanded regions less disturbing by making the font smaller
Not Free:
Resharper
Visual Assist X
JustCode
ViEmu
CodeRush with Refactor! Pro
VisualSVN
VS10x Code Map - displays a graphical nested representation of the current editor window code
VS10x Editor View Enhancer
NuGet
NuGet (formerly NuPack) is a free, open source developer focused package management system for the .NET platform intent on simplifying the process of incorporating third party libraries into a .NET application during development.
PowerCommands (free)
AnkhSVN (free)
Even if you use other SVN shells outside VS (like TortoiseSVN), I recommend to install this Source Control Provider to automatically keep track of file renames, deletions and the like.
Visual Assist X(not free)
Ghost Doc (Free)
It takes a while to configure it properly, but it can be quite useful.
From my blog post (all free):
Word Wrap with Auto-Indent
Indentation Matcher Extension
Structure Adornment
This also installs the following extensions:
BlockTagger
BlockTaggerImpl
SettingsStore
SettingsStoreImpl
Source Outliner
Triple Click
ItalicComments
Go To Definition
Spell Checker
Remove and Sort Using
Format Document
Open Folder in Windows Explorer
Find Results Highlighter
Regular Expressions Margin
VSCommands
HelpViewerKeywordIndex
StyleCop
Visual Studio Color Theme Editor
PowerCommands for Visual Studio 2010
Extension Analyzer
CodeCompare
Team Founder Server Power Tools
VS10x Selection Popup
Color Picker Completion
Numbered Bookmarks
DevExpress CodeRush/Refactor! Pro (not free, $249.99)
It's way better than Resharper (which by the way always slowed down my VS to a crawl), it works with C# and VB.NET (including refactoring) and the support and community is excellent. Worth the price tag. And yes, it does support 2010 (in RC at the time of this writing).
Visual Studio Color Theme Editor (free)
I can't code unless my VS2010 has a StackOverflow-like theme.
VisualSVN (not-free)
I personally prefer this over AnkhSVN since its not an SCC provider and doesn't add extra files to my repository.
VisualHG is a Mercurial Source control plugin that drives TortoiseHG from VS. I'm a big fan of Mercurial & DVCS. VisualHG makes it nice n integrated. Git fans - I'm not asking for a flame war. Hg is just my brand.
VSCommands is simply one of the best FREE plugins ot there!
(visual studio gallery link)
DevExpress CodeRush Xpress (free)
tangible T4 Editor plus modeling tools for VS2010 adds IntelliSense and Syntax Coloring to T4 Text Templates (Free)
If you are a Vim aficionado...
VsVim - free
ViEmu - not free (also not yet released)
CodeMaid seems to be pretty useful - it AutoFormats on save which saves a lot of time between developers and code-diffs. (Are there other tools that can use the VS AutoFormat document?)
VS10x Code Map
That is very cool. Easy jumping to property, method. And easy expand collapse region and more.
ReSharper (not-free)
World of VS Default Browser Switcher for easily switching browser in web projects.
Code Contracts Editor Extensions, a free extension which provides information about inherited contracts for the method you're currently working on, and a list of contracts for any methods that you're calling. Unfortunately, the latter feature conflicts with Resharper, but the former still works fine.
RockScroll (free) - Double-click on a word/symbol highlights all occurrences of that word/symbol. Also replaces the scroll bar with a preview of your code, with edit spots and "all occurences" lines highlighted.
Example of use: want to see whether a variable is used anywhere else in current source file? Double-click variable, look at scroll bar for any red highlights.
AtomineerUtils Pro (not free, $9.99 USD) is, in my opinion, better than Ghost Doc. But, just like Ghost Doc or any automatic documentation generator, the generated documentation is meant to be edited to be of any real value.
devColor (Free)
Small tool which underlines hex colors in stylesheets with the correct color. I really like how it integrates into the editor.
CleanProject - Cleans Visual Studio Solutions
How many times have you wanted to send a project to a friend or upload
it to a web site like MSDN Code Gallery only to find that your zip
file has lots of stuff that you don't need to send in it making the
file larger than it needs to be.
bin folder obj folder TestResults folder Resharper folders And then if
you forget about removing Source Control bindings whoever gets your
project will be prompted about that. As someone who does this process
a great deal I decided to share with you my code for cleaning a
project.
I can't live without DPack - especially when working on large projects, makes navigating between files and members much easier. And it's free.
Favorite shortucts:
Alt+U : file browser, filters files as you type
Alt+G : code browser, filters all members as you type
Alt+M : code browser, filters methods in the current file as you type
...and so on. Much easier for me then finding my way around Project Explorer.
Vingy (Free)
Vingy 1.0 is simple, but effective add in for Visual Studio 2010 so that you can search the web in a non intrusive way, and can filter results based on sources.
Vingy http://lh4.ggpht.com/__Mw4iY-4nuY/TKic0LcfKgI/AAAAAAAAA7s/OR82RFQFSU8/s1600-h/image%5B14%5D.png
You can bring up Vingy either by clicking View->Other Windows –> Vingy Search Window from the Visual Studio IDE, or just by high lighting some text in the document and then clicking Tools –> Search Selected Text (Ctrl + 1).
Searching with Vingy is pretty straight forward. You can initiate a Search in two ways.
By typing the text in the Vingy search box and pressing ‘Enter’ or by clicking the ‘Go’ button
By highlighting some text in the editor when you type in Visual Studio, and then pressing Ctrl + 1
This is my list of extensions.
The list on this is pretty comprehensive, so I spent sometime to find the extensions that I need. Here is the snapshot. Hope it will help someone.
I tried installing Codemaid, and it appeared to be a nifty addon, but my Visual Studio response became very slow. Felt like some threads were doing some work all the time when Codemaid was on.
So uninstalling for now.
VSFileNav - (Free) A Find File in Solution tool (cross between SonicFileFinder and Resharper). Lightweight, easy to use and fast (I got sick of the huge startup time with Sonic).
Disclaimer : I wrote this tool.
Plugin to quickly go to any file in solution
Sonic file finder (free)
Fast switching between .h and .cpp file
Macro available here (free)
And that's it =)
WoVS Quick Add Reference
The “Quick Add Reference” extension augments the smart tag that VS shows for unrecognized types giving you a chance to add the corresponding assembly reference for that type plus corresponding “using” clause if needed in a single shot.