On Mar 6, 1:23 am, Davaris <[email protected]> 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

Reply via email to