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.
    • Marco NOVAROM
      Marco NOVARO
      last edited by

      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
      • dailD
        dail
        last edited by

        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
        • Marco NOVAROM
          Marco NOVARO
          last edited by

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors