Author Topic: Command to put paragraph in one line.  (Read 229 times)

flethuseo

  • Senior Community Member
  • Posts: 168
  • Hero Points: 2
Command to put paragraph in one line.
« on: October 30, 2016, 08:18:03 pm »
Hi All,

Is there a command that will do the opposite of reflow-paragraph. I want to take some paragraphs written in this editor and copy them to word, but that does not work well. The only way I can get it to work is if I can make each paragraph be one line in Slickedit and let MS Word handle the word wrapping.

Any help appreciated,
Ted

Graeme

  • Senior Community Member
  • Posts: 1899
  • Hero Points: 215
Re: Command to put paragraph in one line.
« Reply #1 on: October 31, 2016, 11:23:06 am »
You can use a regular expression to change linebreaks to spaces in a selection.

Code: [Select]
   replace_buffer_text('\n',"RI?M*",' ','1','0','0','0','0','0','1');
   copy_to_clipboard();

but if you try to use undo to restore the linebreaks it doesn't work.
Hence you might want to copy to a temporary file first

Code: [Select]
   copy_to_clipboard();
   edit("random-rubbish.txt");
   paste();
   select_all();
   replace_buffer_text('\n',"RI?M*",' ','1','0','0','0','0','0','1');
   _deselect();
   select_all();
   copy_to_clipboard();

Here's a word macro that removes line breaks in a selection - as posted here
http://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_winother/macro-to-delete-new-carriage-returns-new-paragraph/58088de1-38f9-42c9-ae5b-e3cec12ebb69



Code: [Select]
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Set oRng = Selection.Range
  If oRng.Characters.Last = Chr(13) Or oRng.Characters.Last = Chr(11) Then
    oRng.End = oRng.End - 1
  End If
  oRng.Text = Replace(Replace(oRng.Text, Chr(11), " "), Chr(13), " ")
lbl_Exit:
  Exit Sub
End Sub