1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Copy code includes syntax highlight and line numbers?

Discussion in 'Software' started by wuyanxu, 30 Apr 2009.

  1. wuyanxu

    wuyanxu still wants Homeworld 3

    Joined:
    15 Aug 2007
    Posts:
    10,590
    Likes Received:
    231
    anyone know how to get a bit of C++ code into Word with line numbers and syntax highlight (keywords and comments are most important) still intact? :confused:

    just been writing my report, need to put the code in the Appendix, it's only 300 lines due to it's SystemC abstract model instead of some low level clock based complex model.
     
  2. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    Some IDEs will preserve formatting/highlighting when posting into a rich text editor - I believe the Visual Studio line does. My editor (textmate) allows me to export my code as HTML, colors and all.

    There's always the option of taking a screenshot too. Just drop a png (or several) in your Word doc and be done with things.
     
  3. wuyanxu

    wuyanxu still wants Homeworld 3

    Joined:
    15 Aug 2007
    Posts:
    10,590
    Likes Received:
    231
    thanks, Visual studio 2008 express copy the syntax highlighting very well.

    but there's no line numbering :(
     
  4. glaeken

    glaeken Freeeeeeeze! I'm a cawp!

    Joined:
    1 Jan 2005
    Posts:
    2,041
    Likes Received:
    50
  5. Flibblebot

    Flibblebot Smile with me

    Joined:
    19 Apr 2005
    Posts:
    4,649
    Likes Received:
    150
    Just use a numbered bullet list. Each new line of code will start a new number in the list.

    Easy.
     
    wuyanxu likes this.
  6. Krikkit

    Krikkit All glory to the hypnotoad! Super Moderator

    Joined:
    21 Jan 2003
    Posts:
    23,448
    Likes Received:
    368
    Is line numbering enabled in Visual Studio?
     
  7. wuyanxu

    wuyanxu still wants Homeworld 3

    Joined:
    15 Aug 2007
    Posts:
    10,590
    Likes Received:
    231
    yes, line numbers are enabled in Visual Studio 2008 express C++. but it's just enabled in the editor, don't know if there's other enabler.

    those 2 websites are great, but the generated line numbers can't be copied :(

    using numbered bullet list is the answer i think. at first it doesn't work because of Word's attempt at being smart, either no numbering or numbering have indentation just like in the code.

    solved it by paste into WordPad (which accepts Rich text format) enable bulletpoints in WordPad, paste into Word, and change bullet to numbers. then select the numbers and change its colour to the same colour.
     

Share This Page