Hello all,
I have a config file containing file paths.
I am wondering how one would go about searching and replacing the strings in vim.
Here is an excerpt of my file I am modifying in vim, so you guys can get a better idea about the situation:
Code:
Host america
IdentityFile ~/.ssh/id_rsa.local
Host germany
IdentityFile ~/.ssh/id_rsa.local
Host canada
IdentityFile ~/.ssh/id_rsa.local
Host japan
IdentityFile ~/.ssh/id_rsa.local
Host amsterdam
IdentityFile ~/.ssh/id_rsa.local
[...]
I understand the the general format for a [s]ubstitute is:
Code:
:%s/<search string>/<replacement string>/g
I want to replace the line with the file path, so naturally I tried:
Code:
:%s,IdentityFile ~/.ssh/id_rsa.local,this is a test,gc
I changed the delimiter to ",", so that I wouldn't have to mess with correctly escaping the slashes.
After executing the command, vim unfortunately comes back with a "E486: Pattern not found: IdentityFile ~/.ssh/id_rsa.local" result. This is certainly not correct, since we can see the string is in the file above.
I assume that I need to escape something else, but I am not sure what or how. Can anyone shed some light on this issue?
Thanks!