I have a bizarre issue where a websites JavaScript files are missing many of the editor functions such as:
handles around code blocks; buttons that allow collapse/expansion
correct line breaks; when pressing enter the cursor goes to the next line but first character position rather than nested per previous line
Keyboard shortcuts missing
Intellisense missing
The dotted line showing the start/end of a nest
and various others.
What I did to get to this:
I have a website in a solution, call it solution A and the JavaScript editing is normal.
This website is going to be moved into a new solution along with other projects.
I created a new empty solution (solution B) and added some solution folders.
I copied the website (via windows exploroer) from solution A to solution B.
Modified the namespace within the csproj file using notepad
Added this website as an existing project to solution B
Performed a find/replace through the code to adjust the namespace to the new one set in D above.
Now when I open my JavaScript files I get none of the functionality listed above.
I have verified that the Text Editor / Javascript/Typescript options are good.
The 2 images below are from copies of the same file in different solutions both running on Visual Studio 2017. The images demonstrate the lack of the collapse/expand button and the dotted lines. Interestingly, all color is correct.
Any ideas what might cause this?
Good JavaScript
Bad JavaScript
After some digging around a colleague found this link talking about a very similar issue - JavaScript intellisense still not working
One of the comments mentioned disabling the 'Language Service' function.
I did this, and sure enough all functionality has returned.
I am not going to mark this as an answer because i've had to disable one thing to cure another. This is just what i have had to do to get JS to edit correctly.
What I am doing right now us updating Visual Studio. It's currently 15.0.26430.4 and 15.4.27004.2002 has just been released. With any luck this resolves the issue.
UPDATE
After updating Visual Studio all is working correctly. Can only assume there was an issue with the Language Service.
Related
I've been trying to think of a better way to title this question, but unfortunately I have no idea how to explain it. Also I haven't found this on stack overflow (for the same reason stated above).
In Eclipse, I used to Ctrl+Click in the name of a method call (in java). And my cursor would jump in to the definition of my method function.
Question 1: Does anyone know the name of this behavior? I mean, maybe it's called function jumping or something like that.
Also I was searching for a plugin like this in Atom editor. Because I've tried to use this a lot of times (bad habits) and didn't work.
Question 2: Name of the plugin to do this in Atom?
Don't know if it helps, but I'm coding in JavaScript at the moment in Atom editor.
As the other answer noted, alt-click over a method/function name can jump you directly to where it was originally defined. It works within the same file, but it doesn't seem to work across files.
The closest Atom editor package I've found for javascript which allows you to jump to function/method definitions across files is called TernJS.
Once installed, you can use ctrl-shift-r over the word (function/method, variable etc) to bring up a list of where that method/function is defined (includes line # & filepath). You can then click on the list item & it will jump you to the definition.
Here is a video I made containing an example of using this atom package.
http://www.youtube.com/watch?v=cFAzqvYoHJs&t=11m58s
To answer your first question this 'behavior' is knows as 'go to definition', or 'jump to definition'.
To answer your second question some packages you could perhaps take a look at would be,
'goto-definition'
'code-peek'
I find these help a bit but still don't achieve the standards that I would fully like. I wanted something similar to the Intellij IDEA ctrl + click.
I find myself using the ctrl + shift + f to search the entire project for the related files of the thing I'm searching for. Then I find the particular file i'm looking for and shazam! I've got what I came to get. This particular method works best for me.
I know its not exactly what your looking for but this is the best thing I've found so far to achieve something similar to what we both seem to be looking for. Hope this helps a bit,
happy coding...
Currently this behavior is blocked by multiple cursors feature.
The closest you can get is "ctrl-alt-shift-d" + atom-ternjs
try atom/navigate
Link to Atom Navigate
It helps you to do this excact thing.
The only thing is that it's default key is f2 instead of cltr+click
But this is also editable in the package settings in de .atom file
I don't think I have a package for that.
Simply ctrl-D goes to definition for me.
Tried by luck after reading here other methods.
Cheers.
In Atom (1.57.0 version, os Ubuntu 18.04) command ctrl+shift+f is doing project-find:show. (try cmd+shift+f if on mac and the above does not work)
First select a function name in a file within a project, click ctrl+shift+f, and a list of files from your project folder, that also have this function (either defined, or used) should appear.
Click on any of these files, to come back to the list use ctrl+tab. I can see in key-bindings that this command project-find:show, is bound to ctrl+shift+f, and I have used it, but I am not sure if this is from one of the packages, or not. (sorry new to atom)
I am working with the new Visual Studio 2013 that now also has better support for embedded javascript code inside ASPX-Pages.
Since I there are some ASPX pages that have pretty much javascript code on it, I am collapsing the functions I don't need. However the next time I open the ASPX page in the editor the functions are all expanded again...
I am now asking: Does anyone know if there is a setting or something that enables to keep them collapsed, once they got collapsed by me? Just like it works for methods / classes collapsed in .cs files.
I also could not find a direct solution for this, so I looked up information regarding macros in Visual Studio. I found that recording the collapse operation (Ctrl+M) on the specified functions and running this macro at each startup solved my problem temporarily, but not after extensive change in my code.
I would recommend looking into parametering macros for an easy to maintain, semi-automatic code-collapse on startup. This is not a read-and-go answer, but it can give you some hints on where to start a workaround.
http://msdn.microsoft.com/en-us/library/b4c73967(v=vs.90).aspx
I have been using Eclipse for some weeks now and I start getting used to it.
However, one thing really annoys me:
When editing JavaScript (I didn't try any other language yet), the editor window keeps jumping to the start of the document I am editing.
This mostly happens when the code currently contains syntax errors and mostly while / after deleting lines.
Especially constructs like { = and sometimes unterminated strings / comments seem to cause this problem.
When it happens, only the view scrolls to the top of the document - the cursor stays where it was before the "jump" occurred.
Anyone having an idea on how to fix this?
I believe the problem described above is related to this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318095
The work around is to disable the "Link with Editor" option from the Project Explorer. Which is to say make sure the icon with two arrows facing in opposite directions at the top of the file tree is not enabled. Disabling this option resolved the issue for me.
Looks like a problem with the implementation of the JavaScript editor. Most probably the jump occurs when the JavaScript-Parser is not able to parse your document and throws an exception. You might consider to report a bug to the eclipse project (maybe there is already such a report?).
As a workaround you might consider to adapt your way of typing the code a bit. Try to write the code in a way that does not confuse the parser (for example it might help to immediately close a newly created comment and THEN write the content instead of open the comment, write the content and finally close the commend). Same for strings, blocks ...
I am having the same problem. I had this line of code in my file and I could consistently reproduce the issue:
$.preload(preloadImages
, {
base:assetsUrl+'b/images/',
ext:'.png'
});
I changed it to the following and I no longer have the problem.
$.preload(preloadImages, {
base:assetsUrl+'b/images/',
ext:'.png'
});
I get this Phenomenon, when i'm editing in a Java-Class while still residing in a Debug-Process. The Debugger recognises the Change and reevaluates the Code and jumps back in order to be able to reexecute only the changed Code.
Hii i got solution goto
Window->Preferences->search autosave
and disble it and hit apply and close button.
this worked for me !
I have two questions:
While editing a source file, it's very convenient to be able to label the current position of cursor and then jump to it later by somehow calling that label. I VIM, there is the marking notion, but I'm not aware of such possibility in Eclipse text editor.
Is there any way in Eclipse to add a portion of the code to the outline window, such that you can easily jump to that part when you click on it? I know that for java source-code, almost all variables and functions are shown there, but what if I have a html/javascript code, in which I'm using jquery functions, and the outline doesn't show these functions.
Any help is appreciated!
I dont have any direct answers for your question.
May be you are looking for the following eclipse features.
Eclipse supports bookmarks, you may use that feature. Also CTRL + Q will go back to the last edited location.
You may be able to get this using the Mylyn, which is packaged along with eclipse by default. Implements the notion of a Task focussed IDE ( RECOMMENDED)
Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting.
Are there any work-arounds or ways to fix this? I'm using vim 7.1.
You might like to try this improved Javascript syntax highlighter rather than the one that ships with VIMRUNTIME.
Well, I've modified Yi Zhao's Javascript Syntax, and added Ajax Keywords support, also highlight DOM Methods and others.
Here it is, it is far from being perfect as I'm still new to Vim, but so far it has work for me. My Javascript Syntax. If you can fix, add features, please do.
UPDATE: I forgot these syntax highlights are only shown if you included them in your own colorscheme, as I did in my Nazca colorscheme. I'll test if I could add these line into my modified syntax file.
Follow the new version of the javascript syntax file in github, for it is no longer required to modify your current colorscheme.
Syntax coloring synchronization probably needs adjustment. I've found in certain contexts that I need to change it.
Syntax synchronization (":help syn-sync") controls how vim keeps track of and refreshes its parse of the code for coloring, so that it can start drawing anywhere in the file.
The defaults don't always work for me, so sometimes I find myself issuing
:syn sync fromstart
I suggest reading through the documentation under
:help syn-sync
or just check
:help syntax
and find the section on synchronization.
to make an informed decision among the four available basic options.
I maintain mappings to function keys to switch between "fromstart" and "ccomment" modes and for just clearing the sync settings.
This is a really old post, but I was experiencing the same thing: sometimes syntax highlight would just stop working when looking at the javascript section in an .html file. As the OP mentions, a quick workaround was to scroll up and then magically things would start highlighting again.
Today I found the underlying problem and a good solution. In Vim, syntax highlighting uses a context to derive the correct highlight, where context is defined by the previous lines. It is possible to specify how many lines before the current line are used by issuing :syntax sync minlines=200. In this case, it will use up to 200 previous lines as context. It is possible to use the whole file (which can be slow for long files) by running :syntax sync fromstart.
Once I found that, I added this line to my .vimrc:
autocmd BufEnter *.html :syntax sync fromstart
By doing so, .html files will use the whole file as context. Thus, the javascript section will always by highlighted properly, regardless of how long the JS section is. Hope this helps someone else out there!
For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. Ctrl+L for a screen redraw can also fix it.