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...
Related
I love Prettier for VS Code. I want to do similar things in Visual Studio (2019).
It now has 'Wrap, indent, and align parameters or arguments' for example (https://learn.microsoft.com/en-us/visualstudio/ide/reference/wrap-align-indent-parameters?view=vs-2019); and I'd like to do this automatically whenever I save the file.
Does anyone know if this is possible? Or if there's a free extension that can do this?
Mads Kristensen (a Microsoft employee who makes scads of Visual Studio extensions and teaches you to too!) made a JsPrettier extension for "classic" Visual Studio (ie, not VS Code):
https://github.com/madskristensen/JavaScriptPrettier
It does not format on save if you set that up in its settings.
If it's literally Prettier in Visual Studio that you're after, this isn't a bad option.
I don't know of a free plugin but you can get quite a long way towards this with some muscle memory and the built in autoformat command.
CTRL+E, CTRL+D, CTRL+S
will do code indentation and formatting, and save the file.
If you have Resharper (sorry), there's a configurable code cleanup tool which will do what you want and CTRL+E, CTRL+F, CTRL+S will do the cleanup and save.
The Format document on Save VS extension does exactly what you want, with one exception. It automatically runs Visual Studio's code cleanup command on save.
Visual Studio's code cleanup commands covers many code style preferences and can be configured with a .editorconfig file. Unfortunately one thing that is not supported by VS yet (not counting Resharper) is line wrap preferences. There is an open ticket for this: dotnet/roslyn#33872
If and when Roslyn supports line wrap preferences (presumably as a new .editorconfig preference), then Visual Studio code cleanup will enforce it and the extension will apply it on save.
Every time I type an emmet string and press tab visual studio replaces it with just the main element. Then i realized it was preferning the the snippet that it was auto suggesting. Is there a way around this or fix it? I am using Visual Studio 2013 Community edition on windows 7 64bit if that makes any difference
I found the problem, I was using another plugin called Viasafora that colors braces and makes it easier to to see your indentations it had a default option for showing completions ans you type. I had to go turn it off.
Whenever I copy code from Visual Studio 2010 to anywhere like Stack Overflow or into a Microsoft Word document or into the editor in Outlook, except for the first line of code, the rest of all the code is indented so far to the right and I have to constantly remove the tabs in each line before posting.
How do I get around this? There surely is a Visual Studio setting in the Edit menu that I have forgotten to use over the years.
UPDATE
In response to Akshay's answer, it appears that I already have that set to "Insert Spaces." Please see picture attached.
There is an option to replace tabs with a fixed number of spaces. In Visual Studio, go to Tools -> Options -> Text Editor
Then choose the language you want to modify, or "All Languages" and select the "Tabs" option. This will let you replace tabs with the desired number of spaces.
The Visual Studio Extension Copy for review may help you (only for Visual Studio 2013 currently, however.)
It currently supports two output formats, both removing leading whitespace, while keeping the indentation as much as possible. Thus, this may improve your experience, together with the tip from Akshay.
Disclosure: I am the author of that Extension. Please notfiy me, if I can improve it to your needs.
I've recently started following the recommendation to use $ as the first character in the name of all jQuery variables, so it's easy to differentiate them from normal JavaScript variables.
Unfortunately the JS editor in Visual Studio 2010 doesn't pick up the $ when I double-click to select a word, or when searching for "whole word".
I know some text editors (Textpad, for example) allow you to tweak which characters are included in words. Is there any way to control this in Visual Studio?
This doesn't really answer the question, but the problem has gone away as the $ symbol is included automatically in VS 2012 and beyond.
I'm trying to print C# code from Visual Studio 2010 to a Konica BizHub Color Printer. Only the line numbers are printing in color. Does anyone know if there is some Visual Studio setting or plug-in to allow the text of the code to be printed in color?
There is a free extension available now, that puts back in color printing. Not all 2008 'features' are supported, but you get color:
http://visualstudiogallery.msdn.microsoft.com/00ec88c2-1553-47d2-8170-3c5baa0c6e44/
It's impossible to do from VS2010 without 3rd party tools. They cut in from production due to time constraints.
There are some tools such as this that have a workaround though
http://www.starprinttools.com/
Or you could always copy and paste into Word or an e-mail or something
Good luck!