21

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.

8
  • So is there nobody that knows of somthing like this? Any idea how dfficult it would be to implement?
    – zeel
    Jan 10, 2012 at 18:19
  • Simply, use Dreamweaver.... :)
    – user79032
    May 11, 2012 at 7:44
  • 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
    May 11, 2012 at 10:40
  • 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
    May 14, 2012 at 17:12
  • 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
    May 17, 2012 at 2:28

8 Answers 8

9

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

This makes it work in plain HTML files as well.

3
  • 1
    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
    – zeel
    Jul 3, 2011 at 4:20
  • 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
    May 15, 2012 at 3:17
  • Surprisingly, this doesn't work for me.
    – Lev
    Apr 8, 2014 at 11:44
8

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.
1
  • 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
    May 6, 2014 at 20:59
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.

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

6
  • 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
    May 11, 2012 at 10:39
  • I don't believe this exists in exactly the same way in Notepad++ or any existing plugin.
    – harrymc
    May 11, 2012 at 12:10
  • Then the question stands, how would I do it?
    – zeel
    May 11, 2012 at 12:47
  • 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
    May 11, 2012 at 13:30
  • While that could be an option, I like NPP, and would still like to find a way to do this in it.
    – zeel
    May 11, 2012 at 14:06
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...

2
  • 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
    May 17, 2012 at 20:28
  • @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
    Oct 18, 2015 at 1:16
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!

1
  • 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
    Sep 27, 2012 at 3:32
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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .