before I knew it; next thing you know; when I came to; all of a sudden
Fixed expression used to describe a sudden realization or an event that happened without the speaker noticing. Often used at the beginning of a sentence to set up a surprising or unexpected situation.
Before I knew it, it had become pitch dark outside.
When he came to, he was standing alone in the room.
Alternate kanji spelling using 付く; equally valid but less common in this fixed expression.
From 気がつく (to notice, to become aware) + と (conditional particle), literally 'when one notices.' The phrase has become a set expression for describing sudden realizations or unexpected transitions.