Convert multiple lines to single line using text editor
Asked Answered
I

3

3

I have the following words each in a line in a text editor

 'about', 
 'above',
 'across',
 'after',
 'afterwards',
 'again',
 'against',
 'all',
 'almost',
 'alone',

Can some help me to convert the above content into a single line using a text editor

'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone',
Isometric answered 29/7, 2020 at 17:2 Comment(3)
simply find <br> and replaceAllFlagship
@Abhishek <br> is not there. I added by mistakeIsometric
You can refer this answer - #13989788. I have also mentioned few methods in my answers that could youFlagship
F
3
  • Using Any Advanced Text Editor :

You could do it in some modern text editors that allow regex find and Replace. In such editors, you can do it using - Click on the Replace button and put \r\n or \n, depending on the kind of line ending (CRLF or LF). In the Search Mode section of the dialog, check the Extended radio button (interpret \n and such). Then replace all occurrences with nothing (empty string)


  • NOTEPAD++ :

In Notepad++, you can do it as :

  1. Select the lines you want to join (Ctrl + A to select all)
  2. Choose Edit -> Line Operations -> Join Lines

  • ONLINE TOOLS :

I have also found an online tool where you could just paste the text and it would remove all the line breaks . Check to see if this tool helps -> https://www.textfixer.com/tools/remove-line-breaks.php or https://codebeautify.org/remove-line-breaks .You could find many such tools online where you could just paste your text and it will remove all the line breaks for you.

Flagship answered 29/7, 2020 at 17:14 Comment(0)
F
2

Using VS Code

enter image description here

Using awk

Assuming your text is in a file called break.txt, and the code below is in a file called `break.awk, then the follwing command will work:

awk -f break.awk break.txt > edited.txt

The output will be in output.txt and your original file will be unchanged.

BEGIN {
  line = ""
}

{
  line = line " " $1
}

END {
  print line
}
Footboy answered 29/7, 2020 at 17:11 Comment(1)
This is an awesome solution. Thanks!Loeffler
H
0

You can do this in any of the more advanced text editors that support regular expressions or some form of control characters by simply replacing \n with a space. It would help to know which text editor you are using, but generally any of them should use the same, or very similar, syntax (YMMV: depending on the OS, some use \n, others use \r\n). To take care of any OS differences, you can use the Regular Expression to match EOL: (\r\n|\n|\r) and replace instances with a space.

-- Edit: I see this was tagged with word. You can replace ^p with a space ( ) character and it will do what you want.

Heda answered 29/7, 2020 at 17:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.