1

Is it possible to print from Notepad++ without word wrap? If so, please explain how.

(Background: When I print blocks of code, I need word wrap turned off because the indentation of the code is more important to me than having all of the line. Word wrap obsures the indentation and therefore the structure of the code.)

0

2 Answers 2

0

If you just want to have each line truncated, the easy way for a one-off thing would be to count how many characters can be printed, and do a find/replace. Then do a find/replace all in regex mode. Search for (.{10}).* (substitute the number of characters to keep) and replace with \1.

Regex explanation:

  • () denotes a capture group. That means anything found within the group is stored in a variable. \1 later references this variable.

  • . means "match anything"

  • {10} means "do the last thing 10 times"

  • * means "do the last thing zero or more times, for as much as possible"

  • .{10} means "match 10 of any character"

  • .* means "match as much as possible"

  • Put together, it means "replace the first ten characters and everything else with just the first ten characters", effectively only keeping the first ten.

Some would say it's better style to format your code such that extremely long lines don't exist in the first place (most languages are fine with expressions over multiple lines).

2
  • I have assigned this as the answer but don't have the reputation on this forum to vote you up. It is not really the answer I was looking for but does offer a [well written and well explained] solution. Rather, I was hoping for a checkbox in a menu or a config file setting because then I wouldn't have to find the line character limit by trial an error for each printer I use. I had not considered the regex approach, so thanks. I can alternatively do a 2D copy from my development environment. May 23, 2014 at 4:43
  • As to code style, I would point out that I didn't mention "extremely long lines". The definition of long varies from person to person; some advocate a line length limit of 80 characters but that seems to hark back to text-based 80x25 monocromatic screen days. Line lengths in the industry have increased significantly with the advent of large monitors, colour syntax highlighting and, more importantly, object-oriented languages. OO introduced much much longer variable naming ie. variables within objects within objects... But, again, it's pretty personal. May 23, 2014 at 4:51
1

This worked for me:

a) Establish how many cols your printer can do - put a couple of lines at the top:

123456789012345678901234567890123456 <units> etc etc

0        1         2         3   <tens> etc       

b) then print that just that first page

then go to the last character in the line and press SHIFT+ALT+ Left click and drag down and to the left to the end of your document- this does a rectangular select.

Ctrl+C and then create a new document and paste in there - all the lines are truncated and should now print fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .