PDA

View Full Version : [ubuntu] Any vi experts out there?



WelshChris
September 10th, 2008, 02:16 AM
I'm trying to delete all occurrences of '.' (i.e. one full-stop) in a document. I'm trying to use global search and replace with

:%s/.//g

Which, of course, doesn't work.

Any help?

Pro-reason
September 10th, 2008, 04:23 AM
The dot is a regular-expression thingy. You have to escape it with a backslash if you want to use it literally.



:%s/\.//g


More specifically, the dot represents “any character”; so, using it unescaped in your example will delete the entire file.

See http://www.zytrax.com/tech/web/regex.htm#intro

WelshChris
September 10th, 2008, 09:24 AM
Ah, of course. Thanks. I'll need to dig out my Mastering Regular Expressions manual..

Pro-reason
September 12th, 2008, 01:07 AM
Happy to help out.

Perhaps you could use the “Thread Tools” menu to mark this as Solved.