Sunday, January 26, 2014

Re: Replacing a string which is in a line and not in the beginning?

You could also use -
:%s/\%>2c- //g

From ":help \%>" - 
               \%>23c Matches after a specific column.
 


On Mon, Jan 27, 2014 at 10:59 AM, Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On 26/01/14 09:04, Niels Kobschätzki wrote:
On 26 Jan 2014, at 6:21, John Little wrote:

I suggest using \zs":

:%s/.\zs- //g

It works but what does the /. in there?

Niels


   :                 start of ex-command
    %                range, the whole file
     s               :s[ubstitute] command
      /              from
       .             any character
        \zs          what will be replaced starts here
           -         (dash-space) replace this
              //     by nothing
                g    everywhere in the line

IOW, replace dash-space by nothing (any number of times per line, in the whole file), but only if preceded by something on the same line.

Best regards,
Tony.
--
Be valiant, but not too venturous.
Let thy attire be comely, but not costly.
                -- John Lyly


--
--
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

--- You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Sibin

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: