--- In [email protected], "Martin Wynne" <[EMAIL PROTECTED]> wrote: > > It's better to replace all multiple spaces with a visible > character such as ~. > Thanks for the tip. I have now written a procedure to do for me if I paste the code into a memo.
procedure TForm1.btnLeftPadCodeClick(Sender: TObject); var ~ i, j: integer; ~ strLine: string; begin ~ for i := 0 to Memo1.Lines.Count - 1 do ~ begin ~~~ strLine := TrimRight(Memo1.Lines.Strings[i]); ~~~ j := 1; ~~~ while (j <= Length(strLine)) and (strLine[j] = ' ') do ~~~ begin ~~~~~ strLine[j] := '~'; ~~~~~ Inc(j) ~~~ end; ~~~ if j > 2 then strLine[j-1] := ' '; ~~~ if strLine <> Memo1.Lines.Strings[i] then ~~~~~ Memo1.Lines.Strings[i] := strLine; ~ end; end; OTOH, a single tilde on the left might achieve the same thing, and is simpler to code: procedure TForm1.btnLeftTildeClick(Sender: TObject); var ~ i: integer; ~ strLine: string; begin ~ for i := 0 to Memo1.Lines.Count - 1 do ~ begin ~ strLine := TrimRight(Memo1.Lines.Strings[i]); ~ if (Length(strLine) > 1) and (strLine[1] = ' ') then ~ strLine[1] := '~'; ~ if strLine <> Memo1.Lines.Strings[i] then ~ Memo1.Lines.Strings[i] := strLine; ~ end; end; Ian.

