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

Re: Search and Replace Across Multiple Files

Expand Messages
  • Ben Fritz
    ... What is the value of your magic option? Try executing :set magic? to see. You also should set up a .vimrc if you have not already done so, and make
    Message 1 of 4 , Mar 8, 2010
    • 0 Attachment
      On Mar 6, 1:23 am, Davaris <david_moff...@...> wrote:
      >
      > %s/var \(.*\) : \(.*\) = \(.*\);/\2 \1 = \3;/g
      > %s/var \(.*\) : \(.*\);/\2 \1;/g
      > %s/function \(.*\)() : \(.*\)/public \2 \1()/g
      > %s/function \(.*\)/public void \1
      > %s/boolean/bool
      >
      > but when I paste in the first line in command mode, it says
      >
      > E486: Pattern not found: var \(.*\) : \(.*\) = \(.*\);
      >
      >

      What is the value of your 'magic' option?

      Try executing ":set magic?" to see.

      You also should set up a .vimrc if you have not already done so, and
      make sure you're in "nocompatible" mode.

      It is also quite possible that some of these patterns will
      *legitimately* not match. For these type of "conversion" replacements,
      I'd suggest using the 'e' flag on the 's' command to allow Vim to
      ignore "pattern not found" errors. So, your commands would become:

      %s/var \(.*\) : \(.*\) = \(.*\);/\2 \1 = \3;/ge
      %s/var \(.*\) : \(.*\);/\2 \1;/ge
      %s/function \(.*\)() : \(.*\)/public \2 \1()/ge
      %s/function \(.*\)/public void \1/e
      %s/boolean/bool/e

      Finally, to execute all these without retyping them, especially if you
      will be using this script again and again in the future, I'd suggest
      putting them into a file, save the file as jc-to-c.vim or something
      more meaningful to you, and use it by loading the file you want to
      convert and using ":source jc-to-c.vim".

      --
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.