If you buy it a lot at the store, make a grocery list before going, and do not get anything that is not on that list. If you buy it randomly out of vending machines, make sure you have a helthy alternative with you. If you do this a lot a home, do some excerisises or go for a walk whenever you feel a craving coming on. I know I had to learn to control my appetite and cravings, and it is hard to gain that will power but you'll feel so much better when you do!
The best thing to do is not have junk food in the house, if you can't stop with eating a single portion. Replace the chips, cookies, etc with fresh cut up veggies, such as carrots, celery, radishes, broccoli, or cauliflower. You'll get the same crunch, but you'll get nutrition instead of the fat and empty calories. If you need the salt, sprinkle on just a tad of sea salt to add a bit of flavor.
If you're looking for sweets, eat an apple, a handful of berries, some watermelon or other fruit. Again, you get the sweetness, but you get nutrition instead of the empty calories.
Another thing is instead of eating out the bag, serve yourself a portion into a bowl or dish, the put the bag away and when your portion is gone, you're done eating - go do something else, like sweep/vacuum the floor, fold laundry, go for a walk, read a book, call someone on the phone - anything that will keep you from reaching for more food.
It's important that you not sit and mindlessly snack in front of the TV, computer, reading a book because it's real easy to eat a lot more when you're paying more attention to the TV or computer or book than to what you're eating. When you serve your snack, sit down at the table and eat it, just like you would a meal. You'll be a lot less likely to overeat and you'll feel fuller when you're finished eating your portion when you've paid attention to what to what you're eating.