1

I'm looking for a good term for removing line-breaks from a piece of text and replacing them with a special line-break marker. (Like how, when quoting poetry, we use "/" to represent a break; though my case is in a software context, the goal being amenability to line-oriented tools like grep.)

Since various RFCs use the term "linear white space" (LWSP) to refer to within-line whitespace (namely tabs and spaces), I'm considering the term "linearize"; but I'm afraid that it might be too opaque, since there are so many other kinds of linearization. I want to use this term as the name of a function/method/procedure/subroutine that performs this transformation, so it should ideally stand on its own and convey at least a rough idea of what the transformation is.

  • Generally speaking, it's called "reformatting". – Hot Licks Aug 30 '15 at 12:32
  • @HotLicks: Thanks for your suggestion. This is definitely an example of reformatting, but I don't think it's at all guessable what reformat(msg) would mean . . . :-/ – ruakh Aug 30 '15 at 15:27
  • You could use makeGrepFriendly(). – jxh Aug 31 '15 at 23:48
2

I would suggest flatten, as it conveys a visual image of what the transformation will achieve.

  • @DogLover The OP requested a term, I provided a term I thought would be serviceable for his/her purpose. I certainly answered the question, though whether my answer is useful to the OP may be a different story. – weirdev Aug 30 '15 at 6:10
  • Absolutely. My decision was influenced by the StackExchange guidelines (i.e. answers are expected to be definitive, contain references, etc.). – Dog Lover Aug 30 '15 at 6:22
  • Thanks for this suggestion. Unfortunately, I think that the term flatten has developed a fairly specific meaning in programming: we "flatten" hierarchical structures (such as nested lists or nested loops) by converting them into non-hierarchical structures, or at least by reducing the number of levels in the hierarchy. (For example, [1, 2, [3, 4], 5] would "flatten" to [1, 2, 3, 4, 5].) So something like flatten(msg) would probably be confusing. – ruakh Aug 30 '15 at 15:31
  • Having thought about this further, I think "flatten" can work as the verb, it just needs a little bit more detail. I think I'll go with flattenToSingleLine (or something along those lines). Thanks again! – ruakh Aug 31 '15 at 4:32
1

In UNIX, the term for this operation has long been referred to as joining, from the ed/sed/vi/emacs command that appends lines end to end.

(.,.+1)j
Joins the addressed lines. The addressed lines are deleted from the buffer and replaced by a single line containing their joined text. The current address is set to the resultant line.
GNU ed Manual


In Vim you can join two lines together, which means that the line break between them is deleted. The "J" command does this.
Vim documentation


M-^
Merge the previous and the current line (delete-indentation). This “joins” the two lines cleanly, by replacing any indentation at the front of the current line, together with the line boundary, with a single space.
GNU Emacs Manual

(The old binding for M-^ used to be join-line, but that command has been turned into an alias for delete-indentation in newer versions of GNU Emacs.)

0

In computer terms you could refer to the line break as the End of Line sequence (EOL) or line delimiter. So you want to operate globally (meaning all occurrences in the file) on the EOL by either:

  • find and replace
  • substitution
  • transliteration

The last term is use in the Perl language http://codewalkers.com/c/a/Programming-Basics/The-Transliteration-Operator-in-Perl/

So as a term, something like line break substitution could work

While the file will now appear flat when viewed in a text editor, I wouldn't use the tewm flatten or linearize. A file is just a sequence of bytes, so it is really linear to begin with. We jut denote EOL as the symbol to add line breaks.

  • Thanks; so I guess your suggestion is replaceLineBreaks(msg)? – ruakh Aug 30 '15 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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