Skip to main content

Use vi editor to insert newline char in replace

In vi to insert a newline character in a search and replace, do the following 

:%s/look_for/replace_with^M/g 

The command above will replace all instances of “look_for” with 
“replace_with\n” (with \n meaning newline) 

Note: To get the “^M”, enter the key combination “ctl-V” then after that (release all keys) press the “enter” key.

Comments

Popular posts from this blog

Find : Multiple files with different strings

Use find command for multiple search string? Yes, we can. find . -type f \( -name "*.xvg" -o -name "*.log" \) We must not forget to have space before -name  in both the above occurrences. Enable Ginger Cannot connect to Ginger Check your internet connection or reload the browser Disable in this text field Edit Edit in Ginger Edit in Ginger ×