• Login
Community
  • Login

C preprocessor highlighting

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 3.7k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Marco NOVARO
    last edited by Apr 26, 2016, 1:23 PM

    Hello, everybody

    I’m new to Notepad++, and I like it… except the way C preprocessor symbols are highlighted.
    In particular, I’d like to see only the keyword highlighted (as in other editors), and not the whole line (as npp is doing). Therefore, I’d like to see a line like:

    #define AAAAA 1000 // Value

    highlighted like: #define (colored) AAAAA (black), 10000 (red, because it’s a number) and the comment (// Value) correctly colored as a comment.
    Reading the documentation, it seems that I should use the property styling.within.preprocessor… which seems not working at all (in my situation).

    Any help would be greatly appreciated.
    Thank you

    1 Reply Last reply Reply Quote 0
    • D
      dail
      last edited by Apr 26, 2016, 1:53 PM

      You are exactly correct. Setting styling.within.preprocessor will actually parse out the preprocessor numbers/strings/etc. However there is currently no way for this to be set directly from Notepad++. Your only option that I know of would be to use a plugin. PythonScript and LuaScript come to mind. I’ll be a bit biased here and show you how to do it with LuaScript since I wrote the plugin. You’ll have to download/install it manually from Github, but if you add the following code to the startup script, then it should mostly work.

      npp.AddEventHandler("OnSwitchFile", function(filename, bufferid)
          if npp.BufferLangType[bufferid] == L_CPP then
              editor.Property["styling.within.preprocessor"] = 1
          end
      end)
      

      Alternatively if you are more familiar with or already have it installed, you would be able to do something like that with PythonScript but I’m not familiar with it enough.

      1 Reply Last reply Reply Quote 0
      • M
        Marco NOVARO
        last edited by Apr 27, 2016, 8:10 AM

        Thank you, Dail! Your LuaScript tool works very well for me: I tried with the PythonScript (as suggested in the wiki), but I get a “general exception” error.

        1 Reply Last reply Reply Quote 0
        2 out of 3
        • First post
          2/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors