search and replace function in vimrc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

search and replace function in vimrc

Samuel Wright
Hi Guys,

Working with vim 7 on win xp here. Trying to add this function to my vimrc

 "Regex to find bad indexitem entries and replace them
 function FixJHIndex()
   silent! %s/\(<indexitem text="\a*.*">\)\_s*<\/indexitem>/\1/g
 endfunction

to find stuff like this

    <indexitem text="Conversions between pixel types">
        </indexitem>

The regular expression works if I call it directly, but when I write

:function FixJHIndex

it just echoes the function definition. What am I missing?

Thanks
Sam
Reply | Threaded
Open this post in threaded view
|

Re: search and replace function in vimrc

Aaron Griffin
On 11/27/06, Samuel Wright <[hidden email]> wrote:
> :function FixJHIndex

:call FixJHIndex
Reply | Threaded
Open this post in threaded view
|

Re: search and replace function in vimrc

Jean-Rene David-2
In reply to this post by Samuel Wright
* Samuel Wright [2006.11.27 11:15]:
> The regular expression works if I call it
> directly, but when I write
>
> :function FixJHIndex
>
> it just echoes the function definition. What am
> I missing?

:function does exactly as documented.

You want:
:call FixJHIndex()

See

:h :call
:h :function

--
JR