Created
January 11, 2020 18:16
-
-
Save chewmanfoo/fc6cadff0be740a045e8adf1e6be1d67 to your computer and use it in GitHub Desktop.
vim search and replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have this file containing a lot of this | |
authorized_cidr = "" | |
concourse_keys = "" | |
encryption_key = "" | |
instance_ami = "" | |
name_prefix = "" | |
postgres_database = "" | |
postgres_host = "" | |
postgres_password = "" | |
postgres_port = "" | |
postgres_username = "" | |
private_subnet_ids = "" | |
public_subnet_ids = "" | |
I need to transform into this: | |
authorized_cidr = "${var.authorized_cidr}" | |
concourse_keys = "${var.concourse_keys}" | |
encryption_key = "${var.encryption_key}" | |
... etc | |
I'm trying vim, like this: | |
%:s:/\(\s*\)\(\w*\)\(\s*\)=\(\s*\)"":\1\2\3= "\$\{var.\1\}" | |
but it doesn't work. It reports the error "Pattern not found: /\(\s*\)\(\w*\)\(\s*\)=\(\s*\)""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
%s/\s*(\w*)\s*=\s*"\zs\ze"/${var.\1}