Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to get simple syntax highlighting working within a file. Here's the setup.

I have an index.php file, which Notepad++ correctly highlights any PHP code between the <? and ?> tags. Inside of this file, I have some Javascript, which is properly recognized between the <script type="text/javascript"> and </script> tags.

However, I have some CSS that is not being properly highlighted. I've noticed this with all of the "themes" I've tried with Notepad++. The code is surrounded by <style type="text/css"> and </style> yet is not being understood as CSS properly.

Any ideas?

Note: Notepad++ does properly highlight individual .css files.

share|improve this question
    
So long as it correctly highlights the mixed PHP and Javascript, there should be no problems recognizing other languages. You might have to look at how NPP implements the mixed-language support, and then tweak the properties for all of PHP, (X)HTML, and CSS to support interleaving the languages... –  Breakthrough Sep 4 '12 at 12:43
add comment

4 Answers

up vote 2 down vote accepted

I use a program called phpDesigner that highlights PHP, HTML, CSS, JavaScript all separately in the same document. It does code completion for each part, even if you do style="fon...".

I had to move to it since I couldn't find any other program that was so good when working with PHP (and all the other languages it uses at the same time), including Notepad++. The one thing I wish it did was syntax highlight SQL strings within PHP (it does fine with just SQL), but maybe in a future version.

share|improve this answer
    
i think its the only program written in delphi i like ;P easy to crack tho ;* –  n00b Sep 4 '12 at 12:56
add comment

I recently tried out Sublime Text 2 which did very well with highlighting files which contained multiple languages. In my case, it was only HTML+CSS+JS but I'm sure it would work well with PHP.

The app is not as feature rich as notepad++ but it is much more aesthetically pleasing.

The demo version prompts the user to purchase the license once in a while, but there is no time limit.

share|improve this answer
    
You may want to read this Meta post: How do I recommend software in my answers? –  DragonLord Sep 24 '12 at 5:51
add comment

For those who are trying to embed different languages into each other I've found tool that allows such type of configuration: http://www.freescripteditor.org/

I personally needed PHP embedded into SQL (yes, in that order).

Configuration files are human readable, so you can change them with text editor (there's also GUI in program itself).

share|improve this answer
add comment

If it works for some things and not others, it is likely just not currently supported in the software, unfortunately. Your code is what it is and if it is working, you wouldn't want to change anything to simply get Notepad++ to highlight things for you.

share|improve this answer
    
Well yes, I understand that my code is working...but I like for my files to be easily readable. It's just a personal preference. :) I was just wondering if it was possible. –  dmackerman Jan 19 '11 at 18:56
    
Yea, sorry my answer wasn't really helpful. Basically what I'm saying is that if it was supported, it would be working. Maybe you can file a bug/feature request through notepad++ on source forge? –  th3dude Jan 19 '11 at 19:36
    
Isn't there a way to create user defined styles? As there are for so many other languages? Or would it be impossible to detect which language is being used inside the file, thus the highlighting would have to apply to everything within the file? On that note, Php and css syntax doesn't or barely overlaps, thus one user defined style should work, almost completely for php within css. Am I missing something? I'm not terribly adept with user defined styles, so I'd love to know if it's worth pursuing. Thanks! –  David Hobs Aug 17 '12 at 21:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.