Remark: I'm working with .tex
(TeX) file.
In TeX code, line break does not affect the output. To produce a new paragraph we have to use the \par
command.
Some TeX editors interpret a blank line as \par
. So the following code
line one here
continues here and so on
New paragraph here
produces the output
line one here continues here and so on
New paragraph here
Since some editors can wrap long lines automatically I like to write my codes with less RETURN as possible. This is better when we want to take care of line numbers.
See the screen-shot:
I'd like to remove the end of lines but keep the blank lines even if they contain only white spaces. After the process I'd like my code like this:
Note that the new code contains only 3 lines.
I tried using tr
but no success.
Edit: after testing the code suggested by @lcd047, I noticed that some problems appear when the line n
contains %
(%
is used to comment in TeX and everything after it in the line is ignored).
So, I guess that I should add the request: if line n
contains %
don't glue n
with n-1
neither don't glue n+1
with n
.