简体   繁体   English

如何在.html文件中为javascript中的notepad ++添加自动完成功能?

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

Notepad++ does auto-complete for html and also for JavaScript. Notepad ++为html和JavaScript自动完成。 but the auto-completion depends on file extension.html file supports completion for html only. 但自动完成取决于文件extension.html文件仅支持html完成。 Is there a way to enable auto-completion for javascript in the script tag of an html file? 有没有办法在html文件的脚本标签中启用javascript的自动完成功能? I mean, other than copying the auto-completion keyword list from "javascript.xml" to "html.xml" files... 我的意思是,除了将自动完成关键字列表从“javascript.xml”复制到“html.xml”文件...

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. 对我来说,获得所需功能的最简单方法是切换到一个默认名为Brackets的编辑器。 It is specifically designed for web development and is completely free and lightweight. 它专为Web开发而设计,完全免费且轻量级。

Another way to do is to create 2 files and code 另一种方法是创建2个文件和代码

  • JavaScript in the second one (but never save it) 第二个中的JavaScript(但从不保存)
  • HTML in the first one (and copy/paste your Javascript between <script> </script> balises) 第一个中的HTML(并在<script> </script> balises之间复制/粘贴您的Javascript)

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. 最好的工作方式(安全性)是使用2个独立的文件:当用户在浏览器中尝试显示源代码时,可以保护您的JavaScript。

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. 顺便说一句,Notepad ++是一个非常快速和智能的编辑器,你可以像JSLint,emmet,nppFTP一样添加补充,通过折叠缩进...并用黑暗改变主题(黑曜石):它就足够了小项目编码。 ;) ;)

You would either need to 你要么需要

  • write your own lexer plugin (may possibly have an issue of conflicting with the internal HTML lexer), or 编写自己的词法分析器插件(可能存在与内部HTML词法分析器冲突的问题),或者
  • modify the source and compile your own notepad++/Scilexer.dll 修改源代码并编译自己的记事本++ / Scilexer.dll

Both are not quick undertakings. 两者都不是快速的事业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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