Search and replace strings with file paths in vim
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 Code:
:%s/<search string>/<replacement string>/g Code:
:%s,IdentityFile ~/.ssh/id_rsa.local,this is a test,gc 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! |
Quote:
Try instead: Code:
:%s,IdentityFile \~/.ssh/id_rsa.local,this is a test,gc |
Hi veerain,
I can't believe I didn't try that. I was thinking it was going to be a lot more complicated. I totally thought it would be an issue related with something regarding "." or something. I guess not. It works now. Thanks again, veerain! ---- On a sidenote, after looking up what "~" actually means, it seems to be a backreference to a previous substitute string. As to how you actually use it is beyond me... If anyone is in the mood to add more details about it, I'd love to learn a bit more. |
All times are GMT -5. The time now is 06:20 AM. |