Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: s/pattern/pattern/g on the commandline ?
This is a bit old, but...
On 2012-02-27 10:38:44 +0000, Peter Stephenson wrote:
> On Sat, 25 Feb 2012 19:24:50 +0100
> <meino.cramer@xxxxxx> wrote:
> > Is there any way to submit commands like
> > 's/<searched>/<replacement>/g' for being applied the whole commandline
> > in one go?
>
> Just as a postscript, it's worth noting the ZLE widgets replace-string
> (which can also be loaded under the names replace-pattern or
> replace-regexp) and replace-string-again. This allows you to do this
> interactively from the command line. See the zshcontrib manual page.
>
> I use
>
>
> # actually autoloaded
> zlewidget() {
> # bindkey KEY to new WIDGET, possibly implemented by optional FUNCTION.
> # FUNCTION defaults to WIDGET and will be marked for autoload -Uz.
>
> local key=$1
> local widget=$2
> local function=${3:-$2}
>
> autoload -Uz $function
> zle -N $widget $function
> bindkey $key $widget
> }
> zlewidget "\e%" replace-regexp replace-string
But after such a replacement, if one wants to revert, "undo" doesn't
work.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author