Recent Posts

control

(Nerd) ^M Removing control characters using VIM

hat tip Matthew Turland

Have you ever opened up a file using VI and found the following?

<?php
    echo '<html>'^M
    echo '<head>'^M
    echo '</head>'^M
    echo '<body>'^M
 
...

That stupid control character from some other horrid text editor is trailing every single line. And you are annoyed enough to Google for an answer. ^M

Now, hopefully you are aware of the powerful regex tools built right into VI. But in this case, the fix is pretty simple, and we won’t have to craft any regFu. After you open your file using VI, we will then use the search/replace functionality. And we will eventually end up with a line that looks like this.

:%s/^M//g

But there is a gotcha to this solution, so you may need to read on to find out more. And before proceeding, press esc to make sure you are not in insert mode.

First type the following.

 Shift + :

Which should just print the colon at the bottom of your screen.

:

Then type this exactly how it looks.

%s/

Now we need to type the control character. You may be thinking “Jared, I will just hit shift + 6 and get that character onto my screen in no time.”. And you are more than welcome to do that, but you would be wrong.

You will need to press the following keys.

Control + V

Which will get you this printed out.

:%s/^

Then type the following.

Control + M

Which should have you ending up with this.

:%s/^M

At this point you can type the rest of the characters exactly how they look.

//g

Which leaves you with a finished line that looks like so.

:%s/^M//g

Press enter, and you will now replace the ^M character with nothing.

Part 2(kinda): Small search and replace example.

This would replace Dog with Cat.

:%s/Dog/Cat/g

Cat with Mouse.

:%s/Cat/Mouse/g

Mouse with Trap.

:%s/Mouse/Trap/g

So our line to replace the ^M character is literally saying “Replace the ^M character with nothing”.

From its vantage, Anxiety attacks!

Posted on August 26, 2009

Lately I have been writing short stories and posting them online.

Why?

My family has always liked my stories. And I grew up in a no bull-shitin’ family. If it was good, it was good. And if it was bad, well it was bad. Plus, I have a hard time connecting with my Mom. I think we are just too alike. So because I enjoy writing and feel that I have a knack for it, I have taken to putting thoughts on digital paper again. To say “I love you” to those I have a hard time saying it to. And as a simple, yet effective therapy.

Really? Therapy?

Well, yeah. Writing is therapy for my mind as it is caught in Anxiety’s web. And the more thrashing my mind does, the more it becomes entangled.  Anxiety that is based on wanting to control and keep safe. An impossible goal. Which is something that I have always struggled with. The wanting to hold on, the desire to keep and protect. But after death entered my world, my mind was left split. It still wanted to love and shelter those around it, but it now knew that it never could. That life would do what life wills.

And here enters the anxiety attacks. And please understand something, I am an insanely logical person. I analyze data and build structures for a living. So if you were to ask my opinion on anxiety attacks pre cataclysm, I would have arrogantly said.

“People need to get their shit together” and would have believed it too.

Where I find myself now, is in a pretty humbled place. I understand with authority that the mind is insanely powerful. That it is beyond our comprehension and may always be. That grief and fear can turn physical, and some of us now must work hard to not allow it to do so.

Sounds insane? Yeah maybe, but it is real. No doubt it is as real as anything in this world.

To reference what I wrote above, writing takes my mind off the web of control. It stops the fear with the understanding of the following.

-No matter how much I want to keep my loved ones safe, I can only do so much
-The web can’t hold me if it is not recognized
-I have to do what everyone else does, and let it go

Writing helps me let go.