Groups | Search | Server Info | Login | Register


Groups > comp.unix.misc > #68

Re: vi command for adding character

From Ivan Shmakov <oneingray@gmail.com>
Newsgroups comp.editors, comp.unix.misc
Subject Re: vi command for adding character
Followup-To comp.editors
Date 2012-03-20 02:04 +0700
Organization Aioe.org NNTP Server
Message-ID <86vcm01kge.fsf@gray.siamics.net> (permalink)
References <7ca3b818-b06c-47aa-9463-a938cf838820@m13g2000yqc.googlegroups.com>

Cross-posted to 2 groups.

Followups directed to: comp.editors

Show all headers | View raw


>>>>> geoffhazel  <geoffhazel@gmail.com> writes:

	[Cross-posting to news:comp.editors and setting Followup-To:
	there, for the question is hardly Unix-specific.]

 > I have a file like this

 > 02/1/2012
 > 02/2/2012
 > 02/3/2012
 > 03/1/2012
 > 03/2/2012
 > 03/3/2012

 > I want it to be 02/01/2012 and so forth, MM/DD/YYYY format with extra
 > 0's as placeholders.

[...]

 > I can find the patterns with /./ but how do I preserve the characters
 > that are there?  I seem to recall there's a way to specify those with
 > some regex but can't recall the details.

	One can reference a \(\)-group from within the s-command's
	replacement text with \1 ... \9, like:

s;/\([0-9]/\);/0\1;

-- 
FSF associate member #7257

Back to comp.unix.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

vi command for adding character geoffhazel <geoffhazel@gmail.com> - 2012-03-19 09:49 -0700
  Re: vi command for adding character Ivan Shmakov <oneingray@gmail.com> - 2012-03-20 02:04 +0700
  Re: vi command for adding character Rui Maciel <rui.maciel@gmail.com> - 2012-05-08 10:07 +0100

csiph-web