I bought a small clipboard years ago. It just perfectly fits a Jr. Legal Pad. I got some adhesive-backed magnets, and put some on the back of the clipboard. Load it with a pad, add a pencil (pens don't always work good writing on a vertical surface), and slap it on the fridge. When I'm running low/out of something, I write it down, and use the list to buy things on the weekly grocery trip. That, or course, was when I was single. I try to stick to that now, but I'm usually NOT the person buying the groceries. I've had a hard time convincing PeppA to use the list, as she just buys what she feels we need.
Now that we live in a place that has a large pantry, I try to keep a minimum par count on a lot of things, like ketchup, mustard, mayo, etc. I even started dating items that come in, with the day they arrive into my inventory, so I can easily rotate stock.
When I would go shopping, I can usually stick to the list pretty good. I usually leave some leeway in my budget to allow for some "impulse" purchases, or "steals", when I catch something on sale that I can use in a month or two.