简体   繁体   中英

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

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...

I was faced with the same dilemma. For me, The most simple way to get the functionality you desire was to switch to an editor that already does this by default called Brackets. It is specifically designed for web development and is completely free and lightweight.

Another way to do is to create 2 files and code

  • JavaScript in the second one (but never save it)
  • HTML in the first one (and copy/paste your Javascript between <script> </script> balises)

Best way to work (for security) is to use 2 separated files : your JavaScript could be protected when the user try show source-code in his browser.

by the way, Notepad++ is a very fast and smart editor, you could just add complements to it like JSLint, emmet, nppFTP, indent by fold... and change it theme by a dark one (Obsidian) : it would be enough for small projects coding. ;)

You would either need to

  • write your own lexer plugin (may possibly have an issue of conflicting with the internal HTML lexer), or
  • modify the source and compile your own notepad++/Scilexer.dll

Both are not quick undertakings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM