vim question

Abigail abigail at abigail.be
Thu Mar 27 13:43:33 GMT 2008


On Wed, Mar 26, 2008 at 08:50:29AM +0100, Rafael Garcia-Suarez wrote:
> On 26/03/2008, asmith9983 at gmail.com <asmith9983 at gmail.com> wrote:
> > I have the following file contents which I'm editing with vim:-
> >
> >       1  The quick brown fox jumped over the lazy dog.
> >       2  The:quick:brown:fox:jumped:over:the:lazy:dog.
> >       3  The quick brown fox jumped over the lazy dog.
> >       4  The quick brown fox jumped over the lazy dog.
> >       5  The quick brown fox jumped over the lazy dog.
> >
> >
> >  I want to place my cursor on the b of brown on line 2, and with a simple
> >  command change all the colons(:) to end of line,  to a space( ). Obviously its
> >  a change to end
> >  of line only, so a g substitute modifier is no good. I've also tried selecting
> >  selecting to end of line with v, visual mode, then applying ! operator with
> >  sed -e 's/:/ /', but it didn't work.
> 
> My two cents:
> 
> /:brown/<CR>
> f:r<space>
> ;r<space>
> ;r<space> (repeat until end of line is reached...)
> 
> Obviously not good for being automatised, but demonstrates the f and ;
> motion commands that I like a lot.


Since all but two ':'s have to be changed, I would use:

  2G:s/:/ /g<CR>0f r:;.

That requires the least thinking for me. And uses only commands that are
there in 'vi' as well.


Abigail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://london.pm.org/pipermail/london.pm/attachments/20080327/f046f658/attachment.pgp


More information about the london.pm mailing list