The bracket matching in VS2008 is a handy feature, but doesn't seem to work for javascript code.
Is there a way to enable it?
If VS can do this its news to me. It also has other annoyances like not allowing you to go directly to a js function (like you can with C#/VB code/CSS)
I'm currently building a web app (client side code heavy) and given up editing js in VS2008 - it just works against me.
Instead I do it all with notepad++ and the functionlist plugin. Upside is that it provides the bracket matching you're after and also splits all my functions out nicely for easier navigation, highlights the code correctly etc.
I don't see using another app as a problem as its only an alt-tab away
Notepad++
Notepad++ Plugin List
I have looked for similar solutions within VS itself but they either don't work exactly how I'd like or (in one case) crash VS.
Related
I checked some websites source code and JavaScript games. The problem is that everything is readable and understandable except for JavaScript code that is isolated on a file with the extension .js. It looks like this:
{Vargas=void0,h=!0,Ge=null,l=!1,AA=component,BA=Infinity,ca=set Timeout,DA=is Nan,m=Math,ea=deconstructionism;function He(a,b){return a.on-load=b}function IE(a,b){return a.on error=b}function ha(a,b) {return a.name=b}
As you can see, it's hard to read this code because of the stupid indentation. I tried to use Microsoft visual web developer and free JavaScript editors to organize the code, but it was all useless!
How can I make it more readable?
The best place to start is to look at other open source java script libraries/modules/plugins. You must have the original code though, because what you see in the browser is already "compiled" for the web to be small and fast.
For the client you have plenty frameworks. Look for example at the list jsfiddle uses (top-left). You can also use this tool to play with javascript without having to install anything. Search on the web for those projects (that jsfiddle uses as libraries) and look into the code.
There is also a server-side javascript library that allows you to write javascript code also for the server (also web apps, the server side of them). This is called Node.js Ceck this page to find out more. In Node.js you have almost an infinite number of open source and small modules: see the node module registry wehre you find the links also to the individual project.
In any case, you certainly need a Github account to play with other's code because most of these projects are stored on Github.
When editing JavaScript inside a script tag the syntax highlighting is much better than when editing myFile.js.
Is there a way to have the same syntax highlighting in a separate file as you have inside a script tag?
I already tested both the stock javascript.vim syntax file and this alternative one:
http://www.vim.org/scripts/script.php?script_id=1491!
edit: please check screen shot:
Left side is inside script tags and :setfiletype html.
Right side is plain javascript with :setfiletype javascript
I know it's been a couple of months, but I wonder if you've found a satisfactory answer yet?
I found the following via :help syntax within vim:
JavaScript and Visual Basic embedded inside HTML documents are highlighted as
'Special' with statements, comments, strings and so on colored as in standard
programming languages. Note that only JavaScript and Visual Basic are currently
supported, no other scripting language has been added yet.
This seems to explain why everything that is does not have its own coloring in javascript.vim is colored "Special" when embedded within HTML. This seems to include variable names, function and method names, and so forth. I like it, too, because it separates variables, etc, from punctuation, etc. Much easier to see that your code is correct.
My vim JavaScript highlighting is awesome, this is my setup:
syntax on
filetype plugin on
syntax enable
au BufRead,BufNewFile *.js set filetype=javascript
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
with the following js-related bundles
jslint
and no specific syntax files
My colorscheme (molokai) takes care of the rest
Hope this helps you
Use vim-javascript. It works pretty well.
In my case installing jelera/vim-javascript-syntax did the trick since vim-javascript plugin by itself didn't apply a nice color syntax. If your language of choice is Javascript (as in my case) I recommend you to follow this great guide. Hope this helps!
I did find a very interesting tool for identify unused css definitions in a web project.
http://www.sitepoint.com/dustmeselectors/
Are there similar tools also for javascript projects?
P.S.
I know there is no program for deterministically finding unused code. But I am looking for a report to identify possible unused code. Then the last decision will always be your own.
Problem is there is no way to be really sure. Suppose the following:
The initial HTML site is practically empty. There is a lot of JS code though, which seems to be unused.
OnLoad, a function is called which launches an AJAX query to the server. The server returns a lot of HTML code, which is the body of the site. This body contains lots of JavaScript functions.
The initial body is replaced with the body received via AJAX. Suddenly, all code is used.
Static analysis utilities are therefore useless. I do not know whether there exists a browser extension that marks all JS usage from a running browser though.
You can try using tombstones to safely locate and remove dead code from your JavaScript.
https://blog.bugsnag.com/javascript-refactoring-with-bugsnag-and-tombstones/
In order to find the unused assets, to remove manually, you can use deadfile library:
https://m-izadmehr.github.io/deadfile/
It can simply find unused files, in any JS project.
Without any config, it supports ES6, JSX, and Vue files:
The one that comes to mind most quickly is Javascript LINT (http://www.javascriptlint.com/) and JSLint (http://www.jslint.com/).
Beware though: the latter hurts your feelings.
I'm writing Processing.js code using Eclipse (with the Aptana plugin), and I'm a little confused by this option in the Javascript preferences:
Enable error filtering inside //novalidate comments
Using Processing.js allows me (and occasionally forces me - for example, it uses the Java "void" instead of the Javascript "function" for method declarations) to do some funky things to javascript syntax that the validator doesn't like. I've got a bunch of error messages that I'd like to silence, but I'd rather use the Eclipse editor because the rest of my site is there.
I've tried sticking "//novalidate" before, after, after the semicolon on the same line, and even at the beginning of the file, but it has no effect. I've also tried adding exclude rules in Preferences -> Validation, but that doesn't seem to do anything, nor does turning off "Javascript problems" in Problems -> Configure Contents... (which I'd like to avoid, because I'm doing regular javascript elsewhere on my site). I can't find any documentation for "//novalidate" on the Aptana website - does anyone have any idea how to use this properly?
Thanks in advance.
Have you tried Aptana Support methods?
Ideally I wanted to use this in TextMate but I didn't find any feature besides the Show Web Preview which is nice for the fact I can set the interval to update the page, but definitely doesn't work for watching any file and also apply syntax highlighting or any format.
One neat example of what I wanted to achieve is to simulate exactly the same behavior as CoffeScript Try Now feature where you can type in one side and see what the file would look like in javascript.
So ideally I would open my .coffee file and then run coffee --watch on terminal which will track any file change for that specific file, so I could just pop another window inside my text editor which will just keep updating the coffeescript .js generated file.
like this, where the window on the left shows the current file and the window on the right shows the file being watched with specific interval.
I am not sure if I was clear enought, if not, please just let me know..
but basically I just want to see in real time what happens to my files after run a specific script but with syntax highlighting and anything else possible.
I am just testing this kaleidoscope app, it is really nice the way the visualization works, no editing is possible neither syntax highlighting features though but it is really good, so it makes me think that something like this would be really nice:
cheers
Emacs can do both of these things (and you're probably better off running it as a Cocoa app).
ediff works similarly to Kaleidoscope (minus the diagonal lines connecting the two revisions) and does let you edit the files without disturbing the diff process. By default you get the versions above one another but you can press | to toggle to side-by-side and m to expand to the full screen width (unfortunately this doesn't work properly with multiple monitors, at least in the version of Emacs I'm using.)
To tail/auto-revert things, there's auto-revert-mode and auto-revert-tail-mode built into Emacs.
emacswiki.org is pretty good if you're trying to figure out how to do something in Emacs, as is (duh) Stack Overflow. Mastering Emacs is a relatively new blog which has some great articles. There's also M-x all-things-emacs which links to some useful screencasts.
You can open the log file in OSX's Console log viewer utility that is used to monitor system logs. Simple as that. It will not show you diff's but it does emulate the tail -f functionality.