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

20

2

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.

zeel

Posted 2011-07-01T06:33:00.987

Reputation: 2 766

@zeel It's kind of amazing how much i wish np++ had this feature too!.. any luck find a solution yet?.. – D.Tate – 2015-10-17T23:29:25.613

So is there nobody that knows of somthing like this? Any idea how dfficult it would be to implement? – zeel – 2012-01-10T18:19:37.257

Simply, use Dreamweaver.... :) – Apple II – 2012-05-11T07:44:51.753

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. – zeel – 2012-05-11T10:40:37.710

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 – Alok – 2012-05-14T17:12:05.937

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. – zeel – 2012-05-17T02:28:14.260

have you browsed through npp plugins? they can be found here: http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Central A plugins by name "Insertion" and "Coldfusion" sound useful.

– tumchaaditya – 2012-05-17T06:57:13.223

@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. – harrymc – 2012-05-17T11:25:10.920

Answers

9

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

This makes it work in plain HTML files as well.

user79590

Posted 2011-07-01T06:33:00.987

Reputation: 261

1No, 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 – zeel – 2011-07-03T04:20:58.380

I think no problem in that as you will select the tag in N++ it will highlight the tags from open and close positions. – avirk – 2012-05-15T03:17:15.793

Surprisingly, this doesn't work for me. – Lev – 2014-04-08T11:44:13.533

5

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.

ZOHAIB

Posted 2011-07-01T06:33:00.987

Reputation: 67

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. – zeel – 2014-05-06T20:59:07.010

1

Very partial answer:

Do not enable in TextFX / TextFX Settings the option "Auto close XHTML/XML ".

Go to the Settings -> Preferences dialog box. Click in the Backup / Auto-completion tab and set the Enable auto-completion option.

This will only let you choose the ending tag name from its prefix.

Personally, I would prefer for Notepad++ the answer of @user79590 over my answer. If both answers are not satisfactory, then I would look for another HTML editor, since I don't believe any other possibility exists for Notepad++.

harrymc

Posted 2011-07-01T06:33:00.987

Reputation: 306 093

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. – zeel – 2012-05-11T10:39:28.603

I don't believe this exists in exactly the same way in Notepad++ or any existing plugin. – harrymc – 2012-05-11T12:10:21.593

Then the question stands, how would I do it? – zeel – 2012-05-11T12:47:25.273

1

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.

– harrymc – 2012-05-11T13:30:25.940

While that could be an option, I like NPP, and would still like to find a way to do this in it. – zeel – 2012-05-11T14:06:41.180

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. – Andrew Backer – 2012-05-15T08:32:07.773

1

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

LWTBP

Posted 2011-07-01T06:33:00.987

Reputation: 111

@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.. – D.Tate – 2015-10-18T01:16:19.177

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. – zeel – 2012-05-17T20:28:49.987

1

This thread may be pretty old, but here is the answer. Use the Plugin Manager (Plugins -> Plugin Manager) and install XML Tools.

Once installed, XML Tools will show up in the Plugins menu item and within its functionality is a "Tag auto close" option.

Cheers!

jason.t.knight

Posted 2011-07-01T06:33:00.987

Reputation: 127

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. – zeel – 2012-09-27T03:32:32.753

1

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.

Edward

Posted 2011-07-01T06:33:00.987

Reputation: 97

1

try install :

Notepad Sharp plugin.

follow this step:

  • Click Plugins > Notepad# > Close last open tag

  • or press ( Ctrl + . )

Notes:
not really good for nested tag. just good for your last open tag.

XML Tools plugin

follow this step:

  • Click Plugins > XML Tools > Tag auto-close

other question similar:
Notepad++ last open tag closing

Notepad++ XML Auto Indent + Tag Closing

HTML Tag Auto Complete in Notepad++?

Notepad++ - Highlight text and insert html <tag></tag> around it

Placing tags around selected text in notepad++

wrap selection around ... in notepad++

user2427906

Posted 2011-07-01T06:33:00.987

Reputation: 31

1

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.

D.Tate

Posted 2011-07-01T06:33:00.987

Reputation: 111