- In order to replace a word with a newline and some other text:
1,$s/Mode/Mode,\\^MUpdateMinMaxDb=1, OverWrite=1, HxRG=SHxRG/g
where Mode is the word you want to replace. To get the ^M, hold down Ctrl-V and press m
- To replace a set of characters with the same characters (along with additional ones):
1,$s/Mode[...]/&/g
where Mode and the three charcters following it is the expression you want to replace. & will contain Mode+the 3 additional characters that follow it.
- To replace a random number with itself (for instance, if you're searching for an expression with the number, but only want to change the characters around it):
1,$s/A\([0-9]\)/B\1/g
The previous syntax will replace occurence of A0, A1, A2, etc. with B0, B1, B2, etc. The \1 refers to the match to the expression in ()'s.
- To replace the first character in each line with 2 spaces:
1,$s/^/ \ /
If more spaces are desired, one can add that number of '\ ' after the last '\ ' in the line.
- To replace the last character on a line with "LL":
1,$s/.\{1}$/LL/g
If more spaces are desired, one can add that number of '\ ' after the last '\ ' in the line.
- To insert '||' at column 33:
1,$s/^(.\{33\}\)/\1||/g
The \(...\)) indicates this is a group.
The group consists of 33 instances (\{33\}) of any character (.) starting at the beginning of the line (^).
The (\1) replaces the group with itself.
SED does not recognize '\t' so use an actual stroke of the TAB key instead