[Edinburgh-pm] vim question

Murray perl at minty.org
Wed Mar 26 02:51:56 PDT 2008

On Wed, Mar 26, 2008 at 12:11:07AM +0000, asmith9983 at gmail.com wrote:
> change all the colons(:) to a space( ). 

Isn't that:

  Shift + v (select whole line)


  : s/:/ /g

> Obviously its a change to end of line only

Hmm, not clear how this fits with "all the colons", but if you just
wanted the last colon replaced:

  Shift + v (select whole line)


  : s/:\([^:]*\)$/ \1/

Which I think expands as:

  :    # colon
  \(   # start group
  [^:] # anything other than a colon
  *    # zero or more of the previous character (aka, not colon)
  \)   # end group
  $    # end of line

Which we replace with a space, followed by the contents of the matched
group (everything after the last colon).

If you want to select multiple lines:

  Shift + v

then use the arrow keys, or j/k to select lines below/above.


  : s/ ... / ... /

More information about the Edinburgh-pm mailing list