vi Notes: global search and replace
When editing a large file with a common word that needs to be replaced throughout the entirety of the script try using the search and replace feature in vi
To perform a global search and replace, use the search and replace command in command mode:
:%s/search_string/replacement_string/g
The %
is a shortcut that tells vi to search all lines of the file for search_string
and what to change it to as listed here in replacement_string
. The global (g
) flag at the end of the command tells vi to continue searching for other occurrences of search_string
.
Thank me later, I just edited a 300 line configuration for NGINX Reverse Proxy to a large complex application environment. Seek and destroy!