Today I learned a few more things about vi while working on an HTML page like how to replace with n (newline). Basically, you need to escape special characters with a backslash “” but the < and > characters don’t need to be escaped. To give a newline, you simply hit which will give you “^M”. So, my full search and replace command looked like this:
Breaking it down… The “%” tells vi to apply the following command to the entire document. The search and replace command is s/search/replace/g where the “g” means global (replace all instances of the search term with the replacement term, not just the first instance). In the </td> HTML tag, the forward slash must be escaped with the backslash character and the newline character ^M is created using <ctrl+v><ctrl+m>.