How do I stop Visual Studio 2017 reformatting JavaScript - visual-studio-2017

I have searched and read lots of threads, and it seems there are a lot of people who are having similar issues, but not this specific one.
Like most people, I am very picky about how my code looks.
For some reason, VS2017 has its own opinions.
When I type the following:
if (something == somethingelse)
{
the very instant I press the key for the curly brace,
Visual Studio reformats everything to:
if(something==somethingelse){
I can tell you that every formatting checkbox under TextEditor->JavaScript is unchecked. As a matter of fact, I have unchecked basically everything in all the languages.
I don't want ANY "help" from Microsoft.
I would really like ALL auto-formatting to go away.

Javascript formatting can be disabled in Tools → Options → Text Editor → JScript → Formatting.

Related

Commit C++ Intellisense suggestion with space bar in VS 2013

I have recently been exploring C++ some after using C# exclusively for quite awhile. I'm using Visual Studio 2013 and the one thing that is bugging me to death is the inability to commit an Intellisense suggestion by pressing the space bar. I have tried to edit the commit character list in Options -> Text Editor -> C/C++ -> Advanced to accept the space bar but so far I've had no luck. Coming from C# this is very aggravating. Does anybody know if it's possible to make such a change? I know I can use Tab or Enter, but in my opinion using Space is far more fluid.
Any information would be greatly appreciated.
UPDATE: Space seems to commit some suggestions but not others. if I type "std::stri", it commits "std::string". Unfortunately, Intellisense won't commit anything created by me or even common keywords. It just adds a space after what I already typed.
Further to my comment on your question, I have installed the trial version of Visual Studio 2013 (Ultimate), and can confirm that space bar does work to complete IntelliSense suggestions. Combining all comments, it would appear that it works in the following versions:
VS 2010
VS 2012
VS 2013
Here is a screenshot of my IntelliSense settings located at Tools > Options > Text Editor > C/C++ > Advanced:
As a last resort you may want to try changing all your settings back to default, as suggested in this answer:
Tools > Import and Export Settings > Reset all settings
UPDATE: After reading JoshC's comments, I have experimented a bit more and I get the problem too. It appears to be related to whether or not the item you are trying to autocomplete is a member of a type or namespace. If it is (e.g. std::string) then space will work. If it is not (e.g. void) then it will not work (but for some reason, tab will work). As per this link, you can manually invoke the "List Members feature" by pressing CTRL+J in which case on a blank line it will include items which are in the global namespace - however this is clearly not a practical solution.
I have no idea why it discriminates between space and tab in this way. If anyone is aware of a workaround please let me know and I will edit this answer again.
The following would seem to imply that there is no solution for C++:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2656132-support-committed-by-pressing-the-space-bar-in-c
When using Visual Studios 2012 for coding in C++, how do you autocomplete code selected in IntelliSense? (see comments)

How do I turn off auto-formatting in VS2013 for C++?

VS2013 has added auto-formatting for C++. My personal opinion on auto-formatting is that it's ultimately harmful for developers but I have to accept not everyone agrees. What bugs me is that I can't seem to disable auto-formatting completely. I have unchecked every checkbox under Tools->Text Editor->C/C++->Formatting->General yet when I type:
void f ()
VS2013 replaces this with
void f()
That's not the code-standard in this specific project which means I have to go back and insert a space. There are other examples where I have to fight against VS.
I don't want to change the spacing settings because
I work in multiple projects with different code standards
I don't believe in auto-formatting so I just want it to get out of my way
I just want VS to not modify my code automatically.
PS. I am not against that VS can format code but I want to invoke that manually
You can turn off automatic C / C++ /C# code formatting by going to the Options dialog from the Tools menu, selecting the Text Editor → C / C++ / C# → Formatting → General page, and unchecking all the boxes there. You'll still be able to manually format when all of the auto-formatting settings are turned off.
I know this isn't exactly the answer you're looking for, but you can preserver that void f () formatting if you go to Tools > Options > Text Editor > C/C++ > Formatting > Spacing and under Spacing for function parantheses you check the option Insert space between function names and opening parentheses of argument list.
I also had this problem and unchecking all the checkboxes in the formatting options did not help.
It turned out that this was caused by an option in the plugin “Visual Assist X” from Whole Tomato Software.
In my case this problem could be solved by going to “Visual Assist Options”-->”Corrections” and unchecking the Checkbox “Format after paste”.
It's a bug in VS 2013 beta that it cannot be turned off completely, see issue submitted by FuleSnabel: http://connect.microsoft.com/VisualStudio/feedback/details/797716/turning-off-auto-formatting-for-vs2013-c-only-seems-to-partial-disable-auto-formatting.
Some possible workarounds:
If you just peek into some projects which have different/weird style: if an unwanted auto-formatting happens, then you can perform one undo step, this should undo only the auto formatting part of the operation and not your contribution. Fortunately these two (or sometimes more auto formatting steps) are not grouped together into one command probably for this exact reason: you can go back and override it. It is annoying though if that happens all the time. You can configure the behavior to match your style, but you say you have project with different code styles.
Tools/Import and Export Settings... - you can export the specific settings for a certain project and then import it later. This will save .vssettings XML format file. If it's about just a specific file type, than it can be just a few kilobytes long. Unfortunately this requires manual steps. The best would be if these settings could be overridden from the solution configuration file or even the project configuration file, could be part of them.
Note, that this second point is problematic if you really work parallel in your projects with simultaneously open Visual Studios. In this case that settings will be saved finally what the last closed VS instance had I think.
Having different auto formatting saved for solutions can be a feature request for next release (certainly not make it to VS 2013). What I usually come across is the tab/space indentation behavior differences, it's the most common difference in project styles. Indentation also can be configured individually for most file types, but as as in your case, projects can differ, and then it becomes annoying.
Just remember that resharper can also override the indentation/formatting settings. You can turn that off by doing this
ReSharper -> Options -> Environment -> Editor -> Editor Behaviour -> Auto-format on closing brace (un-check this).
To turn off automatic brace completion, go to:
Tools > Options > Text Editor > All Languages > General > Automatic brace completion
...then uncheck "Automatic brace completion".
Go to:
Tools->Options->Text Editor->C/C++->Formatting->Spacing
Then deselect or select the boxes that pertain to the code type you are writing.

Visual Studio indentation of function arguments

Visual Studio 2010 indents the following C++ code as:
if (Foo(arg1,
arg2))
{
}
Is there a way to change Visual Studio formatting rules to indent the code as below:
if (Foo(arg1,
arg2))
{
}
No, there's no way "out of the box" to force Visual Studio to indent code that way. It's always going to indent wrapped function parameters with only a single tab.
It turns out that such a style is in accordance with Microsoft's general coding guidelines, and probably why they've written it that way. I don't much care for it either, though, also preferring your style.
But it turns out that you only have to manually indent the first wrapped parameter. Subsequently, when you press Enter, Visual Studio will automatically start the next line underneath your first carefully lined up parameter.
Also remember that (if you've already written the method definitions), you can select multiple lines at a time and use the Tab key to line them all up. You don't have to do one at a time.
In general, there are unfortunately extremely limited code formatting options available for C/C++ code in Visual Studio. The C# programmers get a lot more goodies. You might be able to invest in an add-in or extension like Visual Assist X that gets you more features in the IDE.
I think this is a duplicate of Automatic indentation of arguments list on multiple lines in Visual Studio. In which I provided an answer for Visual Studio 2017.
Under menu Tools → Options → Text editor → C/C++ → Formatting → Indentation → "Within parentheses, align new lines when I type them".
Choose the option "Align contents to opening parentheses.
Try using a tool called Artistic Style (short for astyle). It can customize almost all your required code format. Regards to your indentation format, check its document on max‑instatement‑indent.
Furthermore, this tool can be easily integrated into Visual Studio .NET (check this for a quick setup).

How do you enable auto-complete functionality in Visual Studio C++ express edition?

Please guide me, how do you enable autocomplete functionality in VS C++? By auto-complete, I mean, when I put a dot after control name, the editor should display a dropdown menu to select from.
Thank you.
Start writing, then just press CTRL+SPACE and there you go ...
When you press ctrl + space, look in the Status bar below.. It will display a message saying IntelliSense is unavailable for C++ / CLI, if it doesn't support it.. The message will look like this -
It's enabled by default. Probably you just tried on an expression that failed to autocomplete.
In case you deactivated it somehow... you can enable it in the Visual Studio settings. Just browse to the Editor settings, then to the subgroup C/C++ and activate it again... should read something like "List members automatically" or "Auto list members" (sorry, I have the german Visual Studio).
Upon typing something like std::cout. a dropwdownlist with possible completitions should pop up.
All the answers were missing Ctrl-J (which enables and disables autocomplete).
Goto => Tools >> Options >> Text Editor >> C/C++ >> Advanced >>
IntelliSense
Change => Member List Commit Aggressive to True
VS is kinda funny about C++ and IntelliSense. There are times it won't notice that it's supposed to be popping up something. This is due in no small part to the complexity of the language, and all the compiling (or at least parsing) that'd need to go on in order to make it better.
If it doesn't work for you at all, and it used to, and you've checked the VS options, maybe this can help.
Have you tried Visual Assist X ? Sort of lights up the VS editor.
I came across over the following post:
http://blogs.msdn.com/b/raulperez/archive/2010/03/19/c-intellisense-options.aspx
The issue is that the "IntelliSense" option in c++ is disabled.
This link explains about the IntelliSense database configuration and options.
After enabling the database you must close and reopen visual studio
for autocomplete use 'ctrl'+'space'
'ctrl'+'space' will open C/C++ autocomplete.
Include the class that you are using Within your text file, then intelliSense will know where to look when you type within your text file. This works for me.
So it’s important to check the Unreal API to see where the included class is so that you have the path to type on the include line. Hope that makes sense.
It's enabled by default. Probably you just tried on an expression that failed to autocomplete.
In case you deactivated it somehow... you can enable it in the Visual Studio settings.
Step 1: Go to settings
Step 2: Search for complete and enable all the auto complete functions
I believe that show help

Are there any Visual Studio add-ins for true 'smart tabs'?

'Smart Tabs' concept allows to automatically insert tab character for block indentation and space characters for in-block formatting. It's described here. Unfortunately, Visual Studio's 'smart tabs' option in text editor settings just indents text on enter press. Same name, completely different and near useless thing :). So, maybe someone knows of a visual studio addin that can change how 'tab' key work so it will insert tab characters and space characters according to rules mentioned above? Any hints are welcome.
Update: I need it for C++. According to comments, ReSharper can do something like this, but only for Basic and C#.
I have mapped the tab-button to Edit.FormatSelection in Visual Studio to achieve this and it works very well for me. I have also remapped the normal functionality of tab so that I still can access them (Edit.InsertTab and Edit.TabLeft).
If no one comes up with an "as-you-type" utility, then Astyle with its convert-tabs and indent=tab options will reformat code after-the-fact.
ReSharper does this pretty well, and is highly configurable.
Have you looked at Visual Assist?
It's been a while since I used it (back on VC++ 6.0!), and I can't see a mention of "Smart Tabs" on the home page, but it might be there somewhere.