How can I add autocomplete in notepad++ for javascript in an .html file?

15

5

Notepad++ does auto-complete for html and also for JavaScript. but the auto-completion depends on file extension.html file supports completion for html only. Is there a way to enable auto-completion for javascript in the script tag of an html file? I mean, other than copying the auto-completion keyword list from "javascript.xml" to "html.xml" files...

As suggested on stackoverflow, asking on superuser, as I could not find a satisfactory answer there. If anyone has any idea, please let me know! (I hope I am not the only one having this kind of an requirement! :))

Nikhil

Posted 2011-03-01T12:14:34.863

Reputation: 251

What's wrong with copying the auto-completion keyword list from javascript.xml into html.xml? Seems like a pretty simple solution to me. – heavyd – 2011-03-01T12:25:07.223

Agreed, its simple... but the problem in that is the list/suggestions will be displayed everywhere in the page, even in the non-javascript part..! That becomes cumbersome actually.. listing all javascript suggestions in html.. I am expecting it to handle it a bit more intelligently, if possible! :) – Nikhil – 2011-03-01T12:38:36.970

Short of writing your own lexer as suggested in the StackOverflow answer, I doubt there is an easy way to make this happen. – heavyd – 2011-03-01T13:29:19.127

:( ohk.. So I am the only one with this requirement.. :) anyways.. thanks for your help,heavyd.. Not being a dev for windows applications find it difficult to write a lexer for npp, but if I ever do attempt to learn and try, will reply here for sure! :) – Nikhil – 2011-03-04T03:58:39.257

Answers

12

Autocomplete feature is disabled by default,
but a simple Preferences setup will get you using the new auto-complete feature in no time at all. Go to Settings -> Preferences, and switch to the Backup/Auto-competion tab. At the bottom of that screen you’ll see where you can enable auto-completion, and you can optionally turn on the “show function parameters” feature as well. It works for CSS, PHP, Javascript, and html also.

vissu pepala

Posted 2011-03-01T12:14:34.863

Reputation: 331

With this turned on when I type document. into a script tag it doesn't show me options like document.write or document.getElementById. – user3015682 – 2019-06-17T20:43:28.667