Configure replace from terminal on IOS/IOS-XE

Today I stumbled on a problem that I wanted to replace VPN names in my whole config on CSR1000v.

Instruction on how to do it I’ve found on invaluable Ivan Pepelnjak’s blog

Basically I created a file in Notepad++, replaced what I wanted then I copied the new content to new file on flash via ssh session using the instruction in the link provided above e.g.

CSR1000v-1(tcl)#puts [open "flash:new-running-config" w+] {
+>Current configuration : 9362 bytes
+>!
+>! Last configuration change at 23:43:47 UTC Mon Mar 16 2015
+>!
+>version 15.4
+>service timestamps debug datetime msec
+>service timestamps log datetime msec
+>no platform punt-keepalive disable-kernel-core
+>platform console virtual
+>!
+>hostname CSR1000v-1
+>!
+>boot-start-marker
+>boot-end-marker
+>!
+>!
+>vrf definition VPN1
+> description "MPLS PE1"
+> rd 65100:1
+> !
+> address-family ipv4
+>  route-target export 65100:1
+>  route-target import 65100:1
+> exit-address-family
+> !
+> address-family ipv6
+> exit-address-family
+>!

Afterwards I just replaced current config with the one in file:

configure replace flash:new-running-config

And voila!