vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 80e517ceff0d3426a1213dc1654a0329adf1be72
parent 7f6455403c9191611365b5b486d95e43e87b97aa
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 15 May 2015 23:44:24 +0200

Implement :substitute by invoking sed as a filter

Diffstat:
Mvis.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/vis.c b/vis.c @@ -1560,8 +1560,11 @@ static bool cmd_read(Filerange *range, enum CmdOpt opt, const char *argv[]) { } static bool cmd_substitute(Filerange *range, enum CmdOpt opt, const char *argv[]) { - // TODO - return true; + char pattern[255]; + if (!text_range_valid(range)) + range = &(Filerange){ .start = 0, .end = text_size(vis->win->file->text) }; + snprintf(pattern, sizeof pattern, "s%s", argv[1]); + return cmd_filter(range, opt, (const char*[]){ argv[0], "sed", pattern, NULL}); } static bool openfiles(const char **files) {