Sometimes I need to copy the output of a program running in the command prompt window and paste it as text.

If the output contains long lines they are split by the command prompt window and show up as 2 or more lines in the text editor after pasting.

This command detects such long line (as having exactly 80 characters, last character being non-space) and merges them into a single line.

g/^.\{79}\S$/normal Jx