Article View: comp.editors
Article #2859Re: Counting and appending an integer in VI?
From: Mitchell Wyle
Date: Wed, 26 Jun 1991 09:34
Date: Wed, 26 Jun 1991 09:34
19 lines
1047 bytes
1047 bytes
In <1991Jun26.031232.29957@massey.ac.nz>
R.Singh@massey.ac.nz (R. Singh) asks:
>Assume a file with 10 foxes.
>
>I want to change it to
>
>foxes1
>foxes2
>[...]
>foxes10
>
>Is it possible in VI. [?]
No. Use awk. awk '{print $0 ++i}' < infile > outfile
From inside vi: :%!awk '{print $0 ++i}'
If you do it often, in ~/.exrc, map ;nu :%!awk '{print $0 ++i}'^V^M
If you want to do it only on the current paragraph: }!awk '{print $0 ++i}'
etc.
Technical Details
Message-ID:
<1991Jun26.093449.19748@bernina.ethz.ch>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!cernvax!chx400!bernina!wyleReferences:
<1991Jun26.031232.29957@massey.ac.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!cernvax!chx400!bernina!wyle From: wyle@nessie.cs.id.ethz.ch (Mitchell Wyle) Newsgroups: comp.editors Subject: Re: Counting and appending an integer in VI? Keywords: numbers in vi? no Message-ID: <1991Jun26.093449.19748@bernina.ethz.ch> Date: 26 Jun 91 09:34:49 GMT References: <1991Jun26.031232.29957@massey.ac.nz> Sender: news@bernina.ethz.ch (USENET News System) Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH Lines: 19 Nntp-Posting-Host: nessie