Go Back   United Bimmer Community - BMW Forum > UnitedBimmer- Off Topic > United Off Topic  **FOR MEMBERS ONLY** > Geek Chat
FAQ Members List Calendar Advertise With Us Mark Forums Read

Geek Chat Ask computer questions or just engage in general geek talk on here

Reply
 
Thread Tools
Old 02-20-2006, 10:04 PM   #1
komodo
 
komodo's Avatar

Name: komodo
Title: Administrator
Status: Offline
Join Date: Apr 2005
Location: Athens, GA
Rate My Car: 68 / 340
Your Ride: 1995 M3
Vim Regex

Wow, okay, I was just casually programming a macro to go through a few hundred lines and change ten digit phone numbers in a list in vim from 1234567890 format to 123-456-7890 format (adding the dashes in there).

Anyway, I finished, then looked back at the last command I gave vim, and realized to a non-unix person, that would look scary. Here it is:

[code]
.,.+632s/^\(\d\{3}\)\(\d\{3}\)\(\d\{4}\)/\1-\2-\3$/[/code]

Wow, I need to get out and do something else. Something that looks like that should not be able to be rattled off without thinking.

Haha, it worked though.
__________________

  Reply With Quote
Old 02-20-2006, 10:36 PM   #2
witeshark
 
witeshark's Avatar

Name: witeshark
Title: Suspended License
Status: Offline
Join Date: Apr 2005
Location: Miami FL
Rate My Car: 84 / 340
Your Ride: 89 325i 5 speed
That's awesome
  Reply With Quote
Old 02-20-2006, 10:49 PM   #3
Rooz

Name: Rooz
Title: Upgraded Member
Status: Offline
Join Date: Apr 2005
Location: Charlotte, NC
Rate My Car: 5 / 340
Your Ride: 2003 M5


Sie sprechen englisch?
__________________



VIEW MOD LIST & PICS

I am worth $2,010,238 on HumanForSale.com

Quote:
Originally Posted by Gregg
Umnitza now provides a mechanic to install all parts ordered right in the box! It's their new "Total customer service program" that will eliminate all the haters and keep incompetents from breaking **** and blaming the vendor! When you are all set simply call INS and they will pick him up free of charge.
  Reply With Quote
Old 02-21-2006, 12:04 AM   #4
nick_318is
 
nick_318is's Avatar

Name: nick_318is
Title: Suspended License
Status: Offline
Join Date: Jul 2005
Location: Detroit, MI, I Heart E30s
Rate My Car: 10 / 340
Your Ride: 1991 318is (e30 m42), 2007 Mazdaspeed 3
Harry I could do that in excel in about 2 minutes without your fancy macro. and in access you could have imported the table and assigned an input mask.

I'm making the assumption that your using an office program. If not, nevermind.
  Reply With Quote
Old 02-21-2006, 12:26 AM   #5
komodo
 
komodo's Avatar

Name: komodo
Title: Administrator
Status: Offline
Join Date: Apr 2005
Location: Athens, GA
Rate My Car: 68 / 340
Your Ride: 1995 M3
^^ It's not office, it's VIM... a hardcore unix text editing program.

And two minutes would have taken longer. I'm saying I just kinda rambled that off not thinking in about 10 seconds, then looked back and was like "whoa." haha

http://www.vim.org
Quote:
Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems. Vim is distributed free as charityware. If you find Vim a useful addition to your life please consider helping needy children in Uganda.
Hum, for an example of how it's used...

Say you have this situation:

Quote:
the miv system@
This is a test ofunimportant-stuff-here
If you put the cursor at the beginning of the file and type:
Quote:
{down} w w w w {right} {right} {esc} d $ {up} {esc} : s / \ ( . \ ) i \ ( . \ ) / \ 2 i \ 1 / g {enter} {esc} $ x a . {esc} y y d d p {up} {shift} j $
You get this:

Quote:
This is a test of the vim system.


After you use it for a few years and it becomes natural (not kidding), it looks crazy cool for someone to walk by behind you and see your hands flying around the keyboard hitting random letters and symbols, and the text on the screen is completely warping and changing to whatever you want, haha.

It's an INSANELY effectient word processor though. I absolutely love it, and I do all my programming in it. After you learn vim really well, you can greatly enhance your typing effeciency. No others can touch it.
__________________

  Reply With Quote
Old 02-21-2006, 12:42 AM   #6
nick_318is
 
nick_318is's Avatar

Name: nick_318is
Title: Suspended License
Status: Offline
Join Date: Jul 2005
Location: Detroit, MI, I Heart E30s
Rate My Car: 10 / 340
Your Ride: 1991 318is (e30 m42), 2007 Mazdaspeed 3
ah very cool
  Reply With Quote
Old 02-21-2006, 12:44 AM   #7
komodo
 
komodo's Avatar

Name: komodo
Title: Administrator
Status: Offline
Join Date: Apr 2005
Location: Athens, GA
Rate My Car: 68 / 340
Your Ride: 1995 M3
Quote:
Originally Posted by nick_318is
ah very cool
I edited my post. Check it now.
__________________

  Reply With Quote
Old 02-21-2006, 12:52 AM   #8
witeshark
 
witeshark's Avatar

Name: witeshark
Title: Suspended License
Status: Offline
Join Date: Apr 2005
Location: Miami FL
Rate My Car: 84 / 340
Your Ride: 89 325i 5 speed
Coding is fun
  Reply With Quote
Old 02-21-2006, 12:58 AM   #9
nightdevils
 
nightdevils's Avatar

Name: nightdevils
Title: Senior Member
Status: Offline
Join Date: Feb 2006
Location: Seattle, WA
Rate My Car: 159 / 340
Your Ride: 2001 BMW 530iA
Bah whoever says replacing vim with excel is just plainly wrong... for certain stuff.. unix regexes are world famous, and even ms office utilizes them. but I cant bitch on either side, since I have worked and will work for the opposing forces.
__________________
  Reply With Quote
Old 02-21-2006, 08:52 AM   #10
jms
 
jms's Avatar

Name: jms
Title: ______
Status: Offline
Join Date: Jul 2005
Location: Pittsburgh,PA
Rate My Car: 105 / 340
Your Ride: 99 328I Convertible
I've been using vi (vim's daddy) for at least a dozen years, it is really the only editor (family) to use on *nix (read unix/linux) and even I don't use it to it's full extent. although it did get me a job once. The interview question was:

In vi how do you search and replace every value in a file. (this can be tricky )
  Reply With Quote
Old 02-21-2006, 10:03 AM   #11
nightdevils
 
nightdevils's Avatar

Name: nightdevils
Title: Senior Member
Status: Offline
Join Date: Feb 2006
Location: Seattle, WA
Rate My Car: 159 / 340
Your Ride: 2001 BMW 530iA
Sorry I used vi as well. Solaris by default doesnt come with vim the question for search and replace is actually quite easy:

: %s/old value/new value/g ... the g for global replace
__________________
  Reply With Quote
Old 02-21-2006, 10:10 AM   #12
jms
 
jms's Avatar

Name: jms
Title: ______
Status: Offline
Join Date: Jul 2005
Location: Pittsburgh,PA
Rate My Car: 105 / 340
Your Ride: 99 328I Convertible
Quote:
Originally Posted by ghost
Sorry I used vi as well. Solaris by default doesnt come with vim the question for search and replace is actually quite easy:

: %s/old value/new value/g ... the g for global replace

You are correct sir,
I would have also accepted
:1,$s/old value/new value/g

that question got me a job as an instructor and of all things for the MCSE course. They also had me developing the unix course, but it never got off the ground.
  Reply With Quote
Old 02-21-2006, 11:37 AM   #13
komodo
 
komodo's Avatar

Name: komodo
Title: Administrator
Status: Offline
Join Date: Apr 2005
Location: Athens, GA
Rate My Car: 68 / 340
Your Ride: 1995 M3
Quote:
Originally Posted by ghost
Sorry I used vi as well. Solaris by default doesnt come with vim the question for search and replace is actually quite easy:

: %s/old value/new value/g ... the g for global replace
__________________

  Reply With Quote
Old 02-21-2006, 12:39 PM   #14
nightdevils
 
nightdevils's Avatar

Name: nightdevils
Title: Senior Member
Status: Offline
Join Date: Feb 2006
Location: Seattle, WA
Rate My Car: 159 / 340
Your Ride: 2001 BMW 530iA
what a weird mix of bimmer and unix geeks we are! to the brothas
__________________
  Reply With Quote
Old 02-21-2006, 12:47 PM   #15
jms
 
jms's Avatar

Name: jms
Title: ______
Status: Offline
Join Date: Jul 2005
Location: Pittsburgh,PA
Rate My Car: 105 / 340
Your Ride: 99 328I Convertible
^^ I don't know about you but that's what pays for mine
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:49 AM.

A vBSkinworks Design

 
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Copyright © 2005-2013 UnitedBimmer.com