Frage

I really like the way Dreamweaver deals with autocompletion of XML and HTML documents.

When I type </ it automatically finds the nearest open tag and autocloses it. So when I have this:

<div class="wrapper">
    <h1>Hello, world!</

it gets updated to this:

<div class="wrapper">
    <h1>Hello, world!</h1>

It would be nice using this feature again so I'd like to know if you've encountered a code editor recently which supports it.

I'm especially interested in finding out whether PHPStorm, Eclipse or Notepad++ (maybe NetBeans) can be persuaded somehow perhaps with a nice plugin.

Please note:

I don't want autocompletion to immediately close the tag that I've just entered. I find the below behavior quite annoying:

<div class="wrapper">
    <h1

and when I close the tag it becomes:

<div class="wrapper">
    <h1></h1>

So this is what I don't wish to accept.

War es hilfreich?

Lösung

As far as I know (though I'm not a user of it myself) jEdit, boosted with the XML plugin (available through the Plugin Manager) is capable of doing that.

(I'm sure you've already tried the method described here for Notepad++.)

Andere Tipps

You should really check out Sublime Text:

http://www.sublimetext.com/

It has lots of auto complete features to help speed up your coding. Oh, and it's sexy! I'm not a SublimeText expert, but I know it has a lot of cool 'snippets' that can help speed up coding. Example:
Typing:

aTAB

will produce:

<a href=""></a> 

with the cursor between the double quotes so you can enter the href.
Typing:

div#wrapperTAB

will produce:

<div id="wrapper"></div>

with the cursor between the div tags.

You can also get an extension called Zen Coding, which will let you type things like:

div#wrapper>h1ALT+e

To set you up with:

<div id="wrapper">
    <h1></h1>
</div>

With the cursor between the h1 tags, so you can type 'Hello World!'

Also, it won't immediately close the tag that you've just entered. (like in your 'Please Note')

For Notepad++:

TextFX -> TextFX Settings -> Autoclose XHTML/XML Tag

In NetBeans it works by default in XML and HTTP files.

I love Netbeans. If you are just doing front end work, I'd suggest the PHP packaged one.

EDIT:

On

<div class="wrapper">
    <h1>Hello, world!</

It completes as

<div class="wrapper">
    <h1>Hello, world!</h1>

On

<div class="wrapper">
    <h1

It does not auto-complete, but gives you options of completing the tag.
If a space exists after the <h1 it suggests valid attributes.
After typing > it recommends closing the tag with </h1> and if you allow it your cursor remains before the closing tag allowing you to fill in the content.

I would recommend you give some of the suggestions a try and find which you like best.

I've used Dreamweaver quite a bit in the past and loved that quick method of closing a tag. When I first started using Netbeans that was the one thing I disliked. Today I discovered the setting which might make everything ok.

In Netbeans, go to Tools > Options > Editor > Code Completion and select HTML in the Language menu. Check the box labeled Completion Offers End Tags After Less Than (<) Character.

There is a bug that has been corrected in an upcoming release. http://netbeans.org/bugzilla/show_bug.cgi?id=204227

I would recommend PHPDesigner

PHPStorm will do it without a plug-in, as do all JetBrains products.

Komodo Edit http://www.activestate.com/komodo-edit has this exact behaviour. You can also get Zen Coding for it.

If you want to auto close an open tag when typing </ in Sublime Text 2, please have a look at a plugin I made recently for this exact purpose: https://github.com/kihlstrom/CloseTagOnSlash

Espresso App does exactly this. In fact, I found your question by a Google search where I'm looking to replicate this exact behavior in Sublim (which I've been recently giving a trial run).

But Espresso is a wonderful Mac app which has this exact behavior built in.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top