Question: I want to replace b by a in visual selection.

I have vimscript like this:

```
execute("normal! vip:s/a/b/g")

```

It works in command line mode. But not work in vimscript.

How to fix it?

How to replace the text directly on original text in vimscript?

Answer: 
I would do:

```
execute 'normal! vip' | s/a/b/g

```
I would probably write

```
'{,'}substitute/a/b/g

```

in a function.