![]() |
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. :doh Haha, it worked though. :shades |
That's awesome :type
|
:conf
Sie sprechen englisch? |
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. |
^^ 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:
Say you have this situation: Quote:
Quote:
Quote:
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. :shades |
ah very cool
|
Quote:
|
Coding is fun :nod
|
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.
|
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 ;) ) |
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 :) |
Quote:
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. |
Quote:
|
what a weird mix of bimmer and unix geeks we are! :lol :cheers to the brothas :D
|
^^ I don't know about you but that's what pays for mine :D
|
| All times are GMT -5. The time now is 04:14 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Copyright © 2005-2013 UnitedBimmer.com
Ad Management by RedTyger