53

Until a week ago I was happily coding html.erb files in Notepad++ with syntax highlighting. Then my hard drive crashed.

I reinstalled Notepad++ on my new system but when I open my html.erbs, only a few of them are highlighting properly.

I think the problem might be that most of these files are being considered 'normal text files', where the few that are working are considered 'html files'. I tried 'save as' html file of the same name, but it isn't working. How can I get my syntax highlighting back? This is seriously slowing me down.

sscirrus
  • 55,407
  • 41
  • 135
  • 228

9 Answers9

81

You could try going to Language > H > Html and that should highlight stuff.

Ashley Grenon
  • 9,305
  • 4
  • 41
  • 54
  • 4
    This is the perfect fix if you wish to enable syntax highlighting on a file without the file extension that usually corresponds to the language it's written in. Thanks! – Wingman4l7 Jun 07 '12 at 01:53
  • FYI, this worked but not until I closed the file and then reopened it. – rossdavidh Sep 20 '13 at 15:24
  • 4
    It works like a charm, But what if we want notepad++ to highlight syntax according to file extension, Everytime we open we need to specify language-> H -> HTML – Ahmed Syed Oct 25 '15 at 05:50
  • @MujahedAKAS I had the same question, and resolved by going to *Settings -> Style Configurator* selecting the language (e.g. `LaTeX`) and then adding my file extension to `User ext` – cmhughes Apr 16 '20 at 15:40
79

Just in case, if anyone meets my situation: I had activated Enable global foreground color in panel Settings -> Style configurator..., deactivating it reactivated syntax highlighting.

Emmanuel
  • 13,935
  • 12
  • 50
  • 72
  • 3
    Or selecting another Theme, and then clicking back to your chosen one (different mean to the same end). Thanks. – samus Jul 02 '13 at 17:50
  • Samus Arin's comment (choose another theme) appears to also work on other problems where global foreground color is not the issue. – rossdavidh Oct 22 '13 at 15:22
  • Thanks a lot, and +1. Was struggling with that for several weeks ... – Binarus Sep 14 '22 at 13:47
3

Another possible situation that could cause this is if you install new themes. If the theme doesn't have certain languages defined and you use one of those, then you will lose the syntax highlighting as well.

To Check: Settings -> Style Configurator

Check that the language is there on the left hand side for the current theme you are running.

dwbartz
  • 886
  • 10
  • 13
3

I had the exact same problem and none of the posted solutions worked for me so I digged deeper and found that I mistakenly assigned my user defined extensions twice under Settings → Style Configurator, for example SQL and XML.

Deleting my user defined extension from one language restored the syntax highlighting.

Andreas
  • 5,393
  • 9
  • 44
  • 53
1

So I Know this problem was solved 7 years ago but it's the top result on google so I wanted to add what the solution to my problem.

Under Settings -> Preferences... -> Languages

I had stupidly disabled python without realizing that that's what I was doing, just had to put it back into available items.

zx485
  • 28,498
  • 28
  • 50
  • 59
Gigadrax
  • 19
  • 2
  • 2
    That is if a language is disabled. The answer works but the OP was after syntax highlighting. Maybe quote the chosen answer and add in yours so it works together. – Syfer Feb 07 '18 at 23:23
1

Go to Settings -> Style configurator... then disable Enable global foreground color and Enable global background color. This fixed my problem.

BatMan
  • 13
  • 5
  • That's exactly the same answer as @Emmanuel has given 6 years before ... By the way, I didn't need to disable "Enable background color"; for me, only the foreground color was the problem. – Binarus Sep 14 '22 at 14:05
1

My issue was very dumb but maybe people will have the same:
Some themes apply the same syntax coloring to all elements of the same language (example: python in Ruby Blue theme is just not colored in anything else than white).
Changing the theme to one that differentiates elements of the language I was coding in solved the issue.

Mayeul sgc
  • 1,964
  • 3
  • 20
  • 35
0

I had this problem when reinstalling notepad++ because with the new install, .r source code files were being recognized as REBOL instead of R. I had to manually remove the r file extension from the REBOL key in the langs.xml file. For instructions, see the similar question on the Notepad++ community forum at this link.

qdread
  • 3,389
  • 19
  • 36
0

I was copying PHP code segments and they did not include the <?php imbedded language control tag. Once I added <? at the top of the page the highlighting was activated.

Roy
  • 1