I'm sure this works in VS2010 but is there any way to get snippets to work in .JS files in Visual Studio 2008?
There's a comment from way back in 2007 in ScottGu's post about JS Intellisense that it might have happened, but I would like to know if it has been officially taken off the table.
I don't believe there is. If you look at more of Scott's blogs you will find this one.
http://weblogs.asp.net/scottgu/archive/2009/09/04/asp-net-html-javascript-snippet-support-vs-2010-and-net-4-0-series.aspx
He makes a comment of "Visual Studio has supported the concept of “snippets” for VB and C# in previous releases – but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well."
Related
I'm looking for your help because I'm having a weird issue with the Visual Studio 2015 editor. I have a javascript file that contains a regular expression that uses a lookbehind, something like this:
var regexStr = /(?<=[0-9a-zA-Z]+)(\/{2,})(?=[0-9a-zA-Z]+)/;
For some reason, the question mark is "breaking" the syntax and the code editor shows it as an error, although the regex is working as expected.
Do you guys know if the '(?' is defined as a special char in the Visual Studio 2015 editor?
Greetings fellow programmers!
First thing I would say is that Visual Studio 2015 is a sub-optimal tool for JavaScript development. There are much better tools for web development that are available for free. This could potentially be seen as opinion based, but developers vote with their feet when it comes to tooling and what makes their workflow easier and faster, and very few people are picking VS 2015 for JS development in 2020. So I have to ask, is there a reason you are locked into using particular piece of software and version for JavaScript? Are you open to using a different tool? If so, comment below and I will add a list of choices for editors and IDE's that are more popular choices and that will most likely make your life as a developer easier.
Assuming though that you want to continue using VS 2015, regardless of its myriad flaws, and just want this particular thing solved, I think that what you are seeing may be the result of updated ECMAScript/JavaScript syntax leaving VS 2015 in the dust. It could also be that this was always just a bug. I first suggest ensuring that you have updated the base application as much as VS 2015 will allow you to. Are you using a pro or community version? Even if you stuck with Visual Studio, you could still get a more recent year's version, and if you are already using the community version that update would be free. Once you are sure you have updated the software as much as possible, I would suggest looking for an extension that could help you with this particular issue.
You can search the Visual Studio Extension Marketplace yourself, and I would look for one that offers things like "JavaScript syntax highlighting" or "updated JavaScript grammar".
Here is an extension I just found that may help you as well:
Regex Editor - "IntelliSense, syntax coloring, in-place testing and more for your regular expressions, right inside the editor!"
I am working on an old website that uses the Ext framework. It has a huge .js file at its core. I'm not a front-end web guy, I usually write the server and service side code, so I'm unfamiliar with getting heavy with JavaScript in Visual Studio.
In this file, there's this snippet:
...
// private
onDestroy : function(){
if(this.manager){
this.manager.unregister(this);
}
Ext.Window.superclass.onDestroy.call(this);
},
...
How do I find the 'manager' member there? I can't F12 to it and there's no combobox full of members at the top of the editor.
Is this just how it is with JavaScript? Is it because VS has poor support? Is it something to do with the way the project/files are setup?
Please don't mention alternative IDEs, or if you do, don't pass opinion on them that might get us in trouble with the SO police. Woop, woop.
Well, I gave it a while and no one piped up so, from what I've just seen on //build/ 2013, Visual Studio 2012 is pretty crap with JavaScript and its much improved in 2013, including the 'combobox full of members' at the top, CoffeeScript support and some other recent ECMAScript change support.
I am new to Visual Studio 2012 and Javscript coding. I have two questions i could not find answers on the web:
i have a webforms project and added some js-files to the sript-folder (http://raphaeljs.com/). Now i want to have Intellisense support for that js-library i added. Is that possible?
for what is the "_references.js" file in the scripts folder? I added all the js-library files to that file but it doesn't enable intellisense.
regards
I'm not sure about Visual Studio 2012, but in 2010, if you drag one JavaScript file onto another one it will add a /// <reference name="MyScript.js" /> line at the top of the second file. If the file being referenced is documented you will get quite useful intellisense, though it is still handy even if not for just being able to explore the surface of the API.
There is some good information in this question: IntelliSense for Ajax and JavaScript libraries in Visual Studio
To put it short, Visual Studio is terrible at intelli-sense for javascript. It is still light years behind other IDEs like IntelliJ & WebStorm.
A work around to slap it in line would be to use ReSharper which is a plugin but you need to pay for the license :(
Hope that helps.
Whether you are forced to code javascript in Visual Studio 2010, or insist on using Visual Studio 2010 instead of another IDE, I'm wondering what anyone has done to improve the javascript development experience in VS2010.
I'm asking since javascript support is lacking in Visual Studio 2010. You don't get the the kind of support you get as if you were developing Silverlight apps in C# and XAML. For example, the intellisense doesn't support javascript 1.8.5 (or even 1.6 functions i.e. JSON.Parse), it's difficult to navigate to function or object definitions (no Go To Definition), no Object Browser, Call Hierarchy, and the list can go on.
What have you done to compensate for the VS2010 features that don't exist for javascript? Also, what would be a good feature request to support javascript development; anything that VS2010 should add as an extension or a future release? Also, are there any suggestions to manage the .js code for large projects?
A few things that have helped me so far are the JScript Editor Extensions, and the Web Standards Update. Also, when working in .js files I rely on bookmarks to get back to key places, since the functions of the file aren't visible (as the would be in C#). My feature request would be to add intellisense support by javascript version, similar to how you can target .NET 2.0, 3.5, or 4.0.
There are a number of VS extensions to assist with javascript:
Visual Studio Javascript extensions feature comparison
JSEnhancements is awesome, and does what you really want: adds regions and code block collapsing.
Also see this extension: http://code.google.com/p/js-addin/
which parses your script into an object tree that can be used for navigation.
I have also used the free version of this editor: http://www.yaldex.com/JSFactory_Pro.htm
I can't recommend it, unfortunately, because it suffers from a couple critical problems (awkward UI, freaky intellisense, and not entirely stable). Which is too bad because it's a very thoughtfully designed piece of software by and large, it just fails where the rubber meets the road.
1) Install Resharper, helps a lot when building javascript heavy web apps.
2) Get FireBug for debugging.
3) Also, the JQuery.vsdocs files are sometimes helpful!
While I use vim and Notepad++ to cut code, I feel your pain, or did until I started using Firebug to debug JavaScript. While it many not be exactly fitting for your situation it's invaluable to me in developing Web based apps:
http://getfirebug.com/
Is it possible to create code regions in JS files in Visual Studio 2010?
This method works in 2005, but I can't get working in 2010.
Here is a very cool VS2010 extension for Javascript and CSS outlining
http://jsoutlining.codeplex.com/
Microsoft now has an extension for VS2010 that provides this functionality:
JScript Editor Extensions
The JSEnhancements plugin for Visual Studio addresses this nicely.
Advanced JavaScript Outlining for Visual Studio 11 is now available for VS2012 through the Extension Manger, or at the URL
http://visualstudiogallery.msdn.microsoft.com/4be701d8-af03-40a4-8cdc-d2add5cde46c?SRC=VSIDE
There's an interesting post here : http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html on how to do this using Macros in Visual Studio.
Hope that help.
Update
I just realised that someone has already referenced this link in the comments.
Another great Visual Studio 2012-Extension is Web Essentials 2012.
There are a bunch of cool tools for even TypeScript, LESS and CoffeeScript.
http://vswebessentials.com/
Even though VS extensions installed, I had a unique problem of some of the script blocks not outlining properly, later found that its because of the #Url.Content tag used in the script, simply replaced it with simple string url, the outlining worked....thought of sharing if it helps someone
In VS 2015 you can just create a block around your "region" like this
{ //My little region
function misc()...
var x = '';
//etc...
...
}
Then just collapse that block. Probably on all older versions of Visual Studio as well.