When writing more complex things, there usually is some high level structure that I need to decide on. So I write a comment with a high level step-by-step list of things the function needs to do.
The benefits for me are:
-I can set the design in stone and assure myself the problem is solved in full. Otherwise I might waste time rethinking the decisions as I cant keep every detail in my mind at once and so it will never form a complete whole unless I prove completeness by writing it down.
-I can first solve the problem at high level (actual problemsolving), then later implement it (boring manual work)
-I can implement only part of the steps, and implement rest later (and be certain that I will know what to do next)
-The steps double as good documentation (either turned into comments with code between them, or remain as a single chunk that explains the high level workings)
I would say a single step represents a piece of code that I will almost certainly want to write in a single go. So how big the steps are, and if I make them at all, depends on how I feel at the moment. If I rougly know what Im doing and dont expect distractions from the specific piece of code, Ill just write it directly. Otherwise, Ill write steps to save the knowledge that will not persist in my mind after splitting the implementation work in multiple chunks (my intentions).