Thursday, November 24, 2011

Re: Substitution of text in keywords

Hi,

Clark, David wrote:
>
> I've been using of Vim as my everyday editor for many years but have
> only recently started to program it to do repetitive things for me.
>
> I've written a function to standardise the case of keywords in my code,
> however when I run it it's not just the keywords that are being changed
> - text within quotes are also being changed e.g. in a message.
>
> Here's a snippet of my function:
>
> " create function to standardise code...
> function! StandardiseCode()
> :silent! %s,\s\+$,,
> :silent! %s,^{,Begin,
> :silent! %s,^},End,
> :silent! %s,\<activerow\>,ActiveRow,g
> :silent! %s,\<and\>,And,g
> :silent! %s, \<date\>, Date,g
> endfun
>
> I have a syntax file that defines the keywords, comments etc for the
> code - is there a way to make the substitution work on just keywords?

there is a script called SrchRplcHiGrp.vim on the Vim web-site at
http://www.vim.org/scripts/script.php?script_id=848 which might do what
you want. (I haven't used it myself.)

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

--
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

No comments:

Post a Comment