I program in my head, and yes, I often do see the code in my head. In some sense, it's like a spatial experience, where each file is a different "room", and those rooms have contents of the code.
When I imagine programming something, I make mental plans of what code goes in specific rooms (Files, or directories), and what that code will roughly look like - At first a rough shape, of a class with particular methods, and over time that resolves into more and more detail such as what the methods will do and how they will interact with other parts.
My memory is really bad though, so if I try to come back to this a week later I will have forgotten the whole thing unless I make very detailed notes.