Gas generally results from incomplete absorption of certain nutrients, especially including carbohydrate, resulting in its being used by gut bacteria with the concomitant generation of gas.
I don't get gas at all when I stick to strict paleo, so yes, I avoid foods that cause gas.