Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Remove line breaks from plain text

  1. #11
    Join Date
    Jan 2007
    Beans
    120

    Smile Re: Remove line breaks from plain text

    Very good for me!

    Thanx!

    zeddock

  2. #12
    Join Date
    Jan 2007
    Beans
    120

    Smile Re: Remove line breaks from plain text

    Quote Originally Posted by sandr View Post
    I wrote a script for gedit's Snippets plugin that removes in-paragraph line breaks and retains the others. To install it:
    1. Activate the Snippets plugin (Edit -> Preferences -> Plugins)
    2. Tools -> Manage Snippets -> Add an entry under Global (I called it 'unwrap')
    3. Copy/paste the Python code below into the textbox.
    4. Assign a shortcut key to your liking (I use Ctrl-U)

    Usage: copy text into gedit, select text, press shortcut key.

    Code:
    $<
    # Reverse word wrap: Replace single newline characters between lines by spaces.
    
    import re
    
    r = re.compile('(?<!\n)\n(?=.)')
    return r.sub(' ',$GEDIT_SELECTED_TEXT)
    >
    Zeddock thanx you!!!

  3. #13
    Join Date
    Nov 2005
    Location
    Oh Canada
    Beans
    13
    Distro
    Xubuntu 11.04 Natty Narwhal

    Re: Remove line breaks from plain text

    Quote Originally Posted by joshedmonds View Post
    Thanks Orlox, but gedit wasn't able to find the \t character. It did find the \r but when replaced with a space or nothing did not actually remove the line breaks. Replace also recognises " as a character to search for or insert into the text.

    This might come in handy in future though, so thanks
    FYI, if you need to search for (or replace) line breaks in gedit and most other text editors, you need to search for \n (that's a backslash plus an "n" [for "newline"]).

    I just tested it in Natty replacing newlines with spaces. Works fine.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •