I use a preprocesser to process some code before my verilog compiler.
All preprocesser words start with the ` character



unfortunately its possible to define your own preprocessor words. The only thing that is known is that the word starts with `.

How can I highlight any word starting with `?


You can adapt the solution from Listings language definition keyword suffixes and use the keywordsprefix=<prefix> to specify that anything beginning with tick is considered a keyword:

enter image description here


  • To obtain the a more reasonable display of leading tick, I added upquote=true which requires the textcomp package. There may be a better way to handle the issue of displaying the `.
  • There are limitations of using keywordsprefix=<prefix> which are noted in Listings language definition keyword suffixes.



    numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,%

    `pp_if pp rr
    pp_if `mm zz
    xx `MM PP
    abc def ghi
  • Ok know it gets a bit tricky. i want to do the words starting with ` a different color than the other keywords. I tried with the emph, but then i can't do the prefix stuff.. any suggestions? – Rasmus Nov 22 '12 at 13:55
  • @Rasmus: Since it is called keywordprefix (and with the highlighting of restrictions as pointed out in Listings language definition keyword suffixes) this may not be easily doable, without much hackery (might be useful as a separate question). One solution might be to copy the code for keywordprefix and define emphstyleprefix and try to adapt that.. – Peter Grill Nov 22 '12 at 19:06
  • @Rasmus: Also, if this answered your question you should consider accepting it: How do you accept an answer? – Peter Grill Nov 22 '12 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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