Thread: Vim Regex
View Single Post
Old 02-20-2006, 09: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
Sponsored Links