views:

97

answers:

4

I currently use notepad++ on windows or gedit on ubuntu. Both of them work great with code highlighting and hinting etc. But both of them suffer from a huge flaw. I am yet to find a code editor that can handle this concept:

<?php
// ooh, look I am doing some php
?><a onclick="alert('hay, some javascript in here now!')">
This link is HTML?!</a>
<?PHP
echo("NOW we have some php as well!");
?>

At the moment, I just have to settle for the one language. I want something that can think of a that text as a default as HTML, but notice when sections are PHP. I want those sections of PHP to have there own code hinting and highlighting. Even more, lets say in an 'if else' I exit PHP, write some HTML then back into PHP, I want it to work out how the braces ( '{' and '}' ) should match up and let me know if I have missed one. I want the sections of in-line JavaScript to be picked up as such. I want all of these languages to get checked for syntax!

Damn it, I want to tool that understands more than one language at once!

Extra

Should point out that I am not willing to pay for such luxury :P

My files are saved as '.php'.

Notepad++ is able to to work out that I am using PHP but when I drop out of php and do some HTML and/or some JavaScript.

+2  A: 

Try Eclipse with PDT or IDEs based on Eclipse like Aptana or Zend Studio.
Or try Netbeans. Should all be able to do what you want.

In case you cannot decide which to use, see the various Q&A's on that topic

Gordon
+3  A: 

PHPStorm is probably the most powerful IDE for your requirements. Pricey, but give it a go. I think it's worth it...

Rob Fonseca-Ensor
Probably should of said in question, but I am not willing to pay for such a luxury either :P
thecoshman
It's free for 45 days. tryyyyyy iiiiiiiiit
Rob Fonseca-Ensor
They just announced until mid-September you can buy a personal or small-biz version for $49, $99 after that. It will be well worth the money....the beta is FANTASTIC and will do what you wanted.
patricksweeney
+2  A: 

Emacs, with the nxhtml mode.

Arkh
+1  A: 

gedit, being based on gtksourceview, absolutely does support nested language blocks. If I save your example as .php, I get syntax highlighting for both PHP and HTML.

And indeed for JavaScript in <script> blocks, though not inline event handler attributes. (Which would be tricky because those aren't CDATA, they're HTML: the syntax highlighter would have to know what if (a&amp;&amp;b) represented. Anyway, you don't want to be using event handler attributes.)

bobince