procedure TForm1.Button1Click(Sender: TObject);
var codetext:TRichEdit;
Begin
codetext:=TRichEdit.Create(Form1);
codetext.PlainText:=true;
codetext.text:='{\rtf1\
ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil MS Sans Serif;}}\viewkind4\uc1\pard\f0\fs16';
codetext.text:=codetext.text+StringReplace(text.text, '<', '\b<', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, '>', '>\b0', [rfIgnoreCase,rfReplaceAll]);
codetext.text:=StringReplace(codetext.text, chr(13), '\par', [rfIgnoreCase,rfReplaceAll])+'}';
text.text:=codetext.text;
end;