Loading ...
Sorry, an error occurred while loading the content.

34163Re: Visual block question

Expand Messages
  • Pavol Juhas
    Dec 11, 2003
      On Thu, Dec 11, 2003 at 07:06:46PM -0800, iainduncan@... wrote:
      > >
      > > control-V to highlight the block, then :s/foo/bar/g
      >
      > That doesn't work because it will automatically extend the range of the
      > command to the end of the line, while dropping the /g will only replace the
      > first. So if for example I want to replace only the integers in question in
      > the first four columns, the normal process is insufficient. This
      ...
      > The reason I posted to this list is because the manual specifically mentions
      > this problem and says this may be changed in future versions of Vim. I can't
      > figure out why that change wouldn't be a good idea, as it doesn't make sense
      > to me to have Visual Block behave like non-block visual mode for search and
      > replace. That sounded like a dev issue to me, sorry if should have been on the
      > other list. If I were a good enough programmer, I'd make a patch for my own
      > uses!

      I think it is not that simple to implement visual block
      search/replace. For set ve=all you can extend the selection
      beyond existing text - should :s treat this as spaces? What about
      matches that cross the end of visual block - should they be
      matched? I suspect learning vim regular expressions would be much
      easier than writing a patch. For example to match Pattern after
      the 15th column use
      /\%>15cPattern/
      to match after 15th virtual column use
      /\%>15cPattern/
      or to match pattern that comes rigth after "foo:"
      /\(foo:\)\@<=Pattern

      HTH,

      Pavol
    • Show all 13 messages in this topic