In order to replace each occurrence of "&" to "&&" in the range from the current line to 30 more lines on, I issue :.,+30s/\\&/\\&\\&/g
but Vim says "Pattern not found". I'm escaping the special character "&" by double backslash "\".
Change and repeat Search for text using / or for a word using * . In normal mode, type cgn (change the next search hit) then immediately type the replacement. Press Esc to finish. From normal mode, search for the next occurrence that you want to replace ( n ) and press . to repeat the last change.
Press y to replace the match or l to replace the match and quit. Press n to skip the match and q or Esc to quit substitution. The a option substitutes the match and all remaining occurrences of the match. To scroll the screen down, use CTRL+Y , and to scroll up, use CTRL+E .
Use :s to substitute entire lines in Vim based on a single parameter. For example, substitute every line starting with Do you with Learn more about Vim! using this command: :%s/^Do you .*/ Learn more about Vim!/g. The ^ (caret) symbol matches the beginning of a line, and * matches the rest of the line.
Try not escaping everything - :.,+30s/&/&&/g
seems to work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With