[Vimperator] Search command (s///) plugin
Martin Stubenschrott
stubenschrott at gmx.net
Fri Feb 29 04:30:02 PST 2008
Konstantin wrote:
> Hi All,
>
> Sometimes I need search-and-replace function while editing
> some text for blog or CMS, so I implemented vim's s/// command.
> It is not very clever by now, it uses first char in a command argument
> as a regexp separator (so it understands s#xxx#yyy#g), but it doesn't
> handle escaped separator chars (so you can not write s#\##!#
> or s/\//-/, you should write s/#/!/ and s#/#-#).
> It parses ALL textareas and input with type=text on page.
> Anyway it's just functionality I need, so any improvements are welcomed! :)
Wow, that's impressive! And with so little code, great.
I don't know when I (or other devs) find time, but i'll probably add
this piece of code to CVS.
Some notes (party to myself, or to any other who wants to merge that
with vimperator CVS):
1.) var tab = ...; Acutally just using window.content should be enough.
2.) with changing getElements... to an XPath query
(vimperator.buffer.evaluateXPath()), the code could even be made
more compact
3.) Better documentation :)
4.) command is s[ubstitute] not just "s";
5.) Maybe we should just substitute the text in the last input field?
And only in all textboxes with (harder) :%s/.../../ or (easier) :s!/foo/bar/
However, these are just small nit picks, thanks a lot for that piece of
code.
--
Martin
More information about the Vimperator
mailing list