Notepad++ auto complete HTML end tags after </ (like Dreamweaver does)

53,037

Solution 1

Go to TextFX / TextFX Settings and check "auto close XHTML tags".

This makes it work in plain HTML files as well.

Solution 2

Yes, it's possible to do in Notepad++, and it's very easy to do. Follow these steps:

  1. Go to Settings.
  2. Click on the Preferences tab.
  3. Now click on Auto Completion. Here, you will see two sections: one is Auto Completion, and the other is Auto Insert.
  4. In the Auto Insert section, click on the check box which says HTML/XML Close Tags.

Solution 3

Using the Notepad++ Notepad# plugin mentioned in @user2427906's answer, and also AutoHotKey, it is possible to close HTML tags in your Notepad++ code after typing </, like in Dreamweaver. Once setup correctly, here is some AHK code you can use to get it to work:

#IfWinActive, ahk_class Notepad++
~<::
Input, UserInput, L1 V
if UserInput=/
    Send, {Backspace 2}^.
return
#IfWinActive

Note: It makes use of the "WinActive" command, so it will only work in a Notepad++ window. Please also note that if you input </ it will first issue 2 Backspace commands before attempting to close the tag, and those characters are deleted whether the tag is closed or not.

In Sum: Notepad# provides you the ability to input Ctrl+. in order to close a tag, which gets us halfway there. And AutoHotKey is then used to map </ to Ctrl+.

Thanks to @user2427906 and also this answer.

Solution 4

If none of the answers above do what you want, you can also submit a feature request to the developer of Notepad++ here:

http://sourceforge.net/p/notepad-plus/feature-requests/

Or, you could develop the plug-in yourself and submit it to the developer.

Solution 5

Maybe you could use HTMLKit which has the shortcut 'ALT+END' which will end your current tag. Maybe N++ has something like that hidden...

Share:
53,037

Related videos on Youtube

dman79
Author by

dman79

Updated on September 18, 2022

Comments

  • dman79
    dman79 over 1 year

    In Dreamweaver typing </ will automatically close the last open tag, so you don't have to type it all out, and it helps if you aren't sure if you closed one or not. Is there a plugin that dose this for Notepad++?

    This is not like text FX where typing the opening tag/bracket adds the close on the other side of the cursor. This behavior is an auto completion that happens when </ is typed, DW finds whatever the innermost open tag is, and closes it. I find that, when I have the option of using DW, I will use this feature far more often than anything else that DW provides. Thus I would love to know if there was a way to do it in NPP.

    Here is DW preference in question:
    enter image description here
    Notice how there is a different option that does what text FX does, but I don't want that.

    I am not opposed to unorthodox suggestions, some kind of macro, or hack of a plugging. Anything to emulate the functionality. If need be, I could write a plugin, I just have no idea how to go about it.

    • dman79
      dman79 over 12 years
      So is there nobody that knows of somthing like this? Any idea how dfficult it would be to implement?
    • user79032
      user79032 about 12 years
      Simply, use Dreamweaver.... :)
    • dman79
      dman79 about 12 years
      I would, if I could afford to. I have had times in the past where I had access to using DW, and I loved it, but I do not have the means to own it for myself.
    • Alok
      Alok about 12 years
      Eclipse does autocomplete, though I do think its too heavyweight for just editing html. +1 for the question, I use NPP too and would be nice to have such a plugin
    • dman79
      dman79 about 12 years
      Less than 24 hours to go. Still none of the answers are deserving of the bounty. It will go unrewarded if nobody gives a better one.
    • tumchaaditya
      tumchaaditya about 12 years
      have you browsed through npp plugins? they can be found here: sourceforge.net/apps/mediawiki/notepad-plus/… A plugins by name "Insertion" and "Coldfusion" sound useful.
    • harrymc
      harrymc about 12 years
      @zeel: Not every request can be fulfilled. Unfortunately. I still believe in my answer; that you have just chosen the wrong tool for what you wish to achieve.
    • D.Tate
      D.Tate over 8 years
      @zeel It's kind of amazing how much i wish np++ had this feature too!.. any luck find a solution yet?..
  • dman79
    dman79 almost 13 years
    No, you see that isn't the same thing. That automatically adds the end tag once you type the opening. so typing <p> gets you <p>|</p> where the | is the typing bar. I want it to give me a close after typing </, the way it dose in Dreamweaver. Dw will find whatever the next open tag is and close it if you type </ you can have 25 open tags and type </ 25 times and they would all be closed in proper order. TextFX is nice when creating a page, but editing it later if I wrap a section in, say, a div I would have to go find the end and type it. Some times that can be a problem. so +1 to Dw
  • dman79
    dman79 about 12 years
    While that is a nice feature, I still have to type the first letter of the tag name ("</d" for a div) and then select the name from the list. The Dreamweaver functionality is automatic.
  • harrymc
    harrymc about 12 years
    I don't believe this exists in exactly the same way in Notepad++ or any existing plugin.
  • harrymc
    harrymc about 12 years
    Change to another editor. From my personal experience I believe that Eclipse works by default the way you wish. Another excellent editor is IntelliJ IDEA (where this is a setting). Both are free and awesome development environments, rather than just editors. An very large list of more editors is to be found in Best Free HTML Editor.
  • dman79
    dman79 about 12 years
    While that could be an option, I like NPP, and would still like to find a way to do this in it.
  • avirk
    avirk about 12 years
    I think no problem in that as you will select the tag in N++ it will highlight the tags from open and close positions.
  • Andrew
    Andrew about 12 years
    Request it as a feature. NPP would have to add real parsing of HTML, etc, to be able to do this. Dreamweaver, being an HTML specific editor, has this. It sounds like you want it to correct errors for you, basically, so you need a real code editor designed for that kind of thing.
  • dman79
    dman79 about 12 years
    Were I to use that I could certainly fake the DW functionality with AHK to turn a </ into an ALT+END. However I do not know of any similar shortcut in NPP. Any one who does might want to pipe in, because they might just get the bounty.
  • dman79
    dman79 over 11 years
    Nope, same thing that TextFX will do. And as I ahve noted, I am not looking for that. I want my closing tage created when I ask for it (in DW I just type '</') not as soon as I complete the first one.
  • Lev
    Lev about 10 years
    Surprisingly, this doesn't work for me.
  • dman79
    dman79 about 10 years
    Once again this is not what I am looking for, I am well aware of this option and it has been suggested before. This behavior is not at all what I am looking for, this ads the closing tag once the open tag is entered, and places the cursor between them. As I have noted to others, I don't want it to do that - I want it to auto complete the closing tag once I start to type the closing tag. This is a feature present in Dreamweaver, type </ and it will complete to the first unclosed tag.
  • D.Tate
    D.Tate over 8 years
    @zeel Don't know if you noticed, but @user2427906 answer mentions the Notepad# plugin which has this functionality. So, by using that in conjunction with Auto HotKey (AHK), we just might have a workaround after all... I'm working on a script right now..