Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I print source code in OS X (HTML/PHP) with number lines and without long line truncation? I was used to Gedit on Linux, but here it seems I can't obtain the same with applications such as TextWrangler or TextEdit.

share|improve this question
add comment

3 Answers 3

up vote 7 down vote accepted

You can print source code with line numbers and without truncation in TextWrangler, the key is Soft wrap text.

  1. Turn on "Soft Wrap Text" under Text Options.

  2. Open TextWrangler > Preferences

  3. Select "Text Printing" then check the "Print line numbers" checkbox.

  4. Print again, long lines should wrap and line numbers should be present.

Note: you may want to set up "Editor Defaults" in TextWrangler's Preferences, and have it Soft wrap text for you for each file you edit, and to a specified width too.

share|improve this answer
add comment

Have you looked at GeSHi? http://qbnz.com/highlighter/demo.php

You didn't specify the purpose for printing out - but I use this to "prettify" any code I expect to be printed - it does line numbering and syntax highlighting for a wide range of languages.

Hope this helps!

share|improve this answer
add comment

enscript in Terminal might be another option. Start with

enscript -CG2rE -U2 my-source-file.PHP

and read the (extensive) man page for additional features.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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