Tuesday, January 24, 2012

Re: Simple substitution question

On 01/24/12 07:02, Guido Van Hoecke wrote:
> gi......Same as i, but leave the cursor on the NERDTree..........
> s.......Open selected file in a new vsplit.......................
>
> I know that
> :'<,'>s/\.\+$//
> would remove all trailing dots.
>
> But why does
> :'<,'>s/\./ /g
> only change the first set of '.' of every line and not the trailing '.'?

Are you sure you you transcribed that correctly? Your second
one, because of the "g" flag does all of the periods on the line.
If you omit the "g" flag, it would do the first period but not
the first group of periods. If you used a mandatory repeat operator:

:'<,'>s/\.\+/ /

it would replace the mass of leading periods with one space
(rather than one space per dot)

-tim


PS: all this is assuming a default Vim without some ill-advised
uses of 'edcompatible' or 'gdefault'. But if you haven't set
either of these, then it shouldn't be an issue.


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: