Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 657037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:46:46+00:00 2026-05-13T22:46:46+00:00

Question: I want code for: syntax highlighting (of programming languages) Language: C# or assembly

  • 0

Question:

I want code for: syntax highlighting (of programming languages)

Language: C# or assembly x86 (preferably C#)

Platform: Windows

Qualifications: most efficient implementation possible / most professional / the way that big corporations like Microsoft do it

Rephrased: How do I implement syntax highlighting in C# for Windows in the most efficient way presently known?




Elaboration (feel free to skip – not needed to answer question :)):

I don’t want just any way of implementing it – I’ve already seen several.

What I’d like to know is how Microsoft does it so well on Visual Studio (whichever version).


People keep trying to reinvent the wheel when it comes to syntax highlighting. I don’t understand why.

Is this considered a very hard problem? I’ve seen implementations that only highlight what’s currently showing on the screen, I think that’s the way to go… (it used some clever API to know which lines of a textbox were actually showing).

I’ve also seen implementations using RichTextBox and I think that’s not the way to go (maybe I’m wrong here) – I think something like subclassing the routine that draws text on the regular textbox and changing its brushes might be better (maybe I’ve seen that somewhere – I doubt I’d think of that myself)

Also I’ve heard that some people implement it with AST just like a compiler would be coded (the lexer part, I think?) – I’d hope that that’s overkill – I don’t see that as being efficient. (uneducated guess)


If it’s indeed a hard problem, then how do the big corps always get it right? I’ve never heard of a way to break the syntax highlighting in Visual Studio, for example.

But any other tool that implements it does so poorly, or worse than the big guys.

What’s the official “this is the best way and any other way is less efficient” way of doing it?


I really don’t have any evidence that Microsoft’s way is better, but seeing that they probably know more about Windows API than anybody else, I’d guess that there way of implementing it is the best (I would love to be wrong – imagine being able to say that my implementation of syntax highlighting is better than MS’s!)


Sorry for the disjointed elaboration.

Also I apologize in advance for any faux-pas – this is my first question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:46:46+00:00Added an answer on May 13, 2026 at 10:46 pm

    I don’t think there is a “this is the best way and any other way is less efficient” way to do it. In reality I don’t think that efficiency is the major problem. Rather complexity is.
    A good syntax highlighter is based on a good parser. As long as you can parse the code you can highlight every part of it in any way you like. But, what happens then when the code is not well-formed? A lot of syntax highlighter just highlight keywords and a few block structures to overcome this problem. By doing this, they can use simple regular expressions instead of having a full-fledged, syntax-error tolerant parser (which is what Visual Studio has).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 408k
  • Answers 408k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From your requirements I think you might be looking for… May 15, 2026 at 6:45 am
  • Editorial Team
    Editorial Team added an answer The hibernate-c3p0.jar provides the class org.hibernate.connection.C3P0ConnectionProvider, a C3P0-based implementation of… May 15, 2026 at 6:45 am
  • Editorial Team
    Editorial Team added an answer Your client's computer clock, date, AND time zone need to… May 15, 2026 at 6:45 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.