See https://golang.org/pkg/regexp/syntax/ for the
supported syntax. Here are some examples:
```
replace "(foo)" "$1-bar"
replace "(foo)" "${1}-bar"
replace "(?P<group>foo)" "$group-bar"
replace "(?P<group>foo)" "$group-bar"
replace "(?P<key>\w+):\s+(?P<value>\w+)$" "$key=$value"
```
Closes #1115
InfoBar.YNPrompt("Perform replacement (y,n,esc)", func(yes, canceled bool) {
if !canceled && yes {
- h.Buf.Replace(locs[0], locs[1], replaceStr)
+ h.Buf.ReplaceRegex(locs[0], locs[1], regex, replace)
searchLoc = locs[0]
searchLoc.X += utf8.RuneCount(replace)
l = util.SliceStart(l, end.X)
}
newText := search.ReplaceAllFunc(l, func(in []byte) []byte {
+ result := []byte{}
+ for _, submatches := range search.FindAllSubmatchIndex(in, -1) {
+ result = search.Expand(result, replace, in, submatches)
+ }
found++
- return replace
+ return result
})
from := Loc{charpos, i}