The main principle of gaining weight is the same for everyone: if you eat more than you burn, your weight will go up. If you are a vegetarian you still need to eat a lot but you need to eat different kinds of food.
Its a bit more complicated since protein from animal sources are complete while plant sources (other than soy) are not complete. This isn’t a problem if you have a balanced diet that encompass vegetables, legumes and grains.
If you are a vegetarian, concentrate on foods that are high in protein such as peas, beans and all kinds of nuts. Since soy is an excellent source, drinking soy milk and eating other soy products (cheese and yogurt) is a good idea for everyone, especially vegetarians.
Another problem is that most plant sources, while relatively high in protein are still low (in calories too) when compared to animal sources. For this reason you’ll need to eat a lot more food. Because of this, supplementing protein might be a good idea. You can buy soy protein powder so your supplementation will be compatible with your vegetarian diet. Avoid whey protein as it is a by product of cheese.