Auto close of html tags and jsp, php, asp tags in notepad++ and a semicolon at the end of the line written of scriptlets

后端 未结 3 1198
执念已碎
执念已碎 2020-12-24 12:03

I use notepad++ and I like it

I specifically want it to do this :

  1. Close automatically HTML tags. (eg.
)
  • Close tags af
  • 相关标签:
    3条回答
    • 2020-12-24 12:20

      For 2. you can't enter custom pairs for auto-complete (in the Auto-Insert section) with two characters. So this is not possible without a plugin. If I find one, I will update my answer.

      1. However, for auto closing code with semicolon ";", you can use this option and "trick" Notepad++ to not put it on every line inside a php tag (which I don't believe is a good use case), but put it only when needed. I tested with ; and ; as opening and closing tags, which essentialy gives you what you need (without the php tags check though) and it's not so nice. But if you use an opening tag of "$" and a closing one ";", then you can get an auto-close functionality whenever you use a variable (which will mean you are writing code).

      Please note that using < and > or any other similar pairs will break other auto-complete functionality (including the auto-close html tags). This is certainly bad, because it would be nice to have both <> auto close and html tags auto-close.

      0 讨论(0)
    • 2020-12-24 12:23

      Regarding auto-closing html tags, for me only having html as the language didn't do the trick.

      (This answer is incomplete, but is too large for a comment given the images.)


      Changing the auto-complete preferences, as below, worked:

      • Settings > Preferences

      settings_prefs

      • Auto-Completion tab > Auto-Insert section > html/xml close tag

      auto-insert

      I use Notepad++ v6.5.2

      0 讨论(0)
    • 2020-12-24 12:39

      If you are editing a PHP file and want it to auto-complete the HTML tags, in addition to turning on "Auto-insert HTML/XML tags" in Preferences, you have to change the programming language to HTML while editing that file.

      In Notepad++, go to the Language menu, and find HTML and click on it.

      This will set the file's language to HTML so that auto-complete tags will work in a PHP file.

      Even with the language set to HTML, it still highlights anything in <?php ?> tags as PHP code, and it does not affect auto-closing of brackets, if you have that enabled.

      You must have Auto-Insert html/xml close tags on, as mentioned in Noha's answer.

      • Settings > Preferences
      • Auto-Completion tab > Auto-Insert section > html/xml close tag
      0 讨论(0)
    提交回复
    热议问题