<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>ClipboardFusion RSS: Simple macro to remove blank lines</title>
<atom:link href="https://www.clipboardfusion.com/Discussions/RSS/?TopicID=c8de789c-ca89-4734-917f-e8bea3dc0b65" rel="self" type="application/rss+xml" />
<link>https://www.clipboardfusion.com/Discussions/RSS/?TopicID=c8de789c-ca89-4734-917f-e8bea3dc0b65</link>
<description>ClipboardFusion RSS: Simple macro to remove blank lines</description>
<lastBuildDate>Mon, 18 May 2026 15:46:18 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.clipboardfusion.com/Discussions/RSS/?TopicID=c8de789c-ca89-4734-917f-e8bea3dc0b65</generator>
<item>
<title>RE: Simple macro to remove blank lines</title>
<link>https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65#4</link>
<pubDate>Fri, 04 Feb 2011 23:10:38 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65#4</guid>
<category>ClipboardFusion</category>
<description><![CDATA[@Splat: Thanks for jumping in and helping out.]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
@Splat: Thanks for jumping in and helping out. <img src="https://www.clipboardfusion.com/MediaCommon/SVGs/FontAwesome/face-smile.light.svg" alt=":)" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:16px;height:16px;" HelpButtonData=":)" HelpButtonDataAlign="BelowMiddle" />
</div>
]]></content:encoded>
</item>
<item>
<title>RE: Simple macro to remove blank lines</title>
<link>https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65#3</link>
<pubDate>Fri, 28 Jan 2011 13:03:12 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65#3</guid>
<category>ClipboardFusion</category>
<description><![CDATA[Hi Splat
you're right it does appear to be the line endings that are different between the "Test Macro" option and what's on the clipboard - I did look for "\n\r" but I didn't try it the way you had the Split function, i.e. the {"\n", "\r"}.
I get SQL statements via email - they look ok in Outl...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hi Splat<br/>
<br/>
you're right it does appear to be the line endings that are different between the "Test Macro" option and what's on the clipboard - I did look for "\n\r" but I didn't try it the way you had the Split function, i.e. the {"\n", "\r"}. <br/>
<br/>
I get SQL statements via email - they look ok in Outlook but when pasted into notepad or wherever they have extra lines in between but this looks like it cures that particular issue.  <br/>
<br/>
I'll take a look at the RegEx stuff - that's really useful, especially as there are so many pre-tested regex examples out there.<br/>
<br/>
thanks again<br/>
<br/>
Chris
</div>
]]></content:encoded>
</item>
<item>
<title>RE: Simple macro to remove blank lines</title>
<link>https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65#2</link>
<pubDate>Thu, 27 Jan 2011 23:02:12 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65#2</guid>
<category>ClipboardFusion</category>
<description><![CDATA[The problem could be that, depending on your text (and OS?), line breaks can either be "\n", "\r", "\r\n", or "\n\r".  Your code only looks for "\n", so if your text also has "/r" as part of the line break, then you code leaves these in, and your output text can still appear to have line breaks....]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
The problem could be that, depending on your text (and OS?), line breaks can either be "\n", "\r", "\r\n", or "\n\r".  Your code only looks for "\n", so if your text also has "/r" as part of the line break, then you code leaves these in, and your output text can still appear to have line breaks.<br/>
<br/>
Try this code instead:<br/>
<div class="col-md-12 BoxWrap"><div class="Box table-responsive"><a name="code" style="width:0; height:0;"></a><h2 class="TableTitle" style="border:0"><div class="TableTitleText">Code</div><div class="TitleButtons"><div class="TableTitleButton"><a href="#" onclick="return false;" data-clipboard-target="#code019e3bc4426a758ea4d9c63e9daadc86" class="ClipboardCopyControl"><img src="https://www.clipboardfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019e3bc4426a758ea4d9c63e9daadc86Js'); return false;"><img src="https://www.clipboardfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Select All</span></a></div></div></h2><div class="TableTitleContent table-responsive"><div class="AceEditorWrapper" style="border-top:solid 1px var(--color-default-border);padding:0"><pre id="code019e3bc4426a758ea4d9c63e9daadc86Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System; 
 
public static class ClipboardFusionHelper 
{ 
    public static string ProcessText(string text) 
    { 
        string[] lines = text.Split( new string[] {"\r", "\n"} , StringSplitOptions.RemoveEmptyEntries);

        text = "";

        foreach (string line in lines)
        {
            text += line + "\r\n";
        }
     return text;
    }
}</pre><textarea id="code019e3bc4426a758ea4d9c63e9daadc86" name="code019e3bc4426a758ea4d9c63e9daadc86" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
This page might help you out : <a href="http://dotnetperls.com/string-split" target="_blank" rel="nofollow"><b>http://dotnetperls.com/string-split</b></a><br/>
<br/>
I have a macro that I have been using that does something similar, but uses Regular Expressions:<br/>
<br/>
<div class="col-md-12 BoxWrap"><div class="Box table-responsive"><a name="code" style="width:0; height:0;"></a><h2 class="TableTitle" style="border:0"><div class="TableTitleText">Code</div><div class="TitleButtons"><div class="TableTitleButton"><a href="#" onclick="return false;" data-clipboard-target="#code019e3bc4426d7376a9a5db8b792c41e1" class="ClipboardCopyControl"><img src="https://www.clipboardfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019e3bc4426d7376a9a5db8b792c41e1Js'); return false;"><img src="https://www.clipboardfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;width:auto;max-width:16px;height:16px;" /><span class="Text">Select All</span></a></div></div></h2><div class="TableTitleContent table-responsive"><div class="AceEditorWrapper" style="border-top:solid 1px var(--color-default-border);padding:0"><pre id="code019e3bc4426d7376a9a5db8b792c41e1Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
  public static string ProcessText(string text)
  {

    // Name:        Clear Blank Lines
    // Description:Clears white space (spaces and tabs) from any line that ONLY contains white space.  Optionally removes the empty lines too.

    bool bolRemoveEmptyLines = true;  // Removes empty lines

    text = Regex.Replace(text, @"^[ \t]+(?[\r\n]{1,2})+", "${linebreak}", RegexOptions.Multiline);

    if (bolRemoveEmptyLines) {
      text = Regex.Replace(text, @"([\r\n]{1,2})+", "\r\n", RegexOptions.Multiline);
      }

    MacroAPI.PasteText(text);  // Optional.  Pastes the text straight away.  Useful when a HotKey is used.
    return text;
  }
}</pre><textarea id="code019e3bc4426d7376a9a5db8b792c41e1" name="code019e3bc4426d7376a9a5db8b792c41e1" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
Using RegEx, it looks for one or both "\r" and "\n" and removes them.<br/>
<br/>
If you just want to clear the empty lines (and not worry about the whitespace), you can just use the last RegEx in the code above.<br/>
<br/>
I haven't fully tested this, but it seems to work well for me.  Let me know if you have any trouble.
</div>
]]></content:encoded>
</item>
<item>
<title>Simple macro to remove blank lines</title>
<link>https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65</link>
<pubDate>Thu, 27 Jan 2011 12:51:49 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.clipboardfusion.com/Discussions/View/simple-macro-to-remove-blank-lines/?ID=c8de789c-ca89-4734-917f-e8bea3dc0b65</guid>
<category>ClipboardFusion</category>
<description><![CDATA[I've created this macro which appears to work fine in the macro editor
[size=10pt]using System;
public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
string[] lines = text.Split( new string[] {"\n"} , StringSplitOptions.RemoveEmptyEntries);
text = "";...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
I've created this macro which appears to work fine in the macro editor<br/>
<br/>
[size=10pt]using System; <br/>
 <br/>
public static class ClipboardFusionHelper <br/>
{ <br/>
    public static string ProcessText(string text) <br/>
    { <br/>
        string[] lines = text.Split( new string[] {"\n"} , StringSplitOptions.RemoveEmptyEntries);<br/>
<br/>
        text = ""; <br/>
<br/>
        foreach (string line in lines)<br/>
        {<br/>
            text += line + "\n";<br/>
        }<br/>
     return text;<br/>
    } <br/>
}[/size]<br/>
<br/>
using the "Test Macro" button but it doesn't appear to do anything to the clipboard when run from tray icon.  I've tried the beta release and it's the same.<br/>
<br/>
I've tried adding "system.collections.generic;" and "system.text;" but that didn't change the results.<br/>
<br/>
- am I still missing something I should be importing? <br/>
<br/>
Chris
</div>
]]></content:encoded>
</item>
</channel>
</rss>