Yes, vinegar can get rid of gnats.
More Info: Gnats can be a pesky problem easily eliminated by using vinegar. There are many home remedies that supposedly get rid of gnats, but using vinegar is easy, inexpensive, and effective.
Cider vinegar can eliminate the pesky gnats that seem to fly everywhere. Use a clean, empty container that has a wide mouth, such as a jar. Fill the container with cider vinegar; tightly cover the top with plastic wrap. It is important to pull the wrap tightly across the container top. Next, poke holes in the top using a fork or toothpick. The gnats will be attracted to the smell of vinegar and fly into the jar, where they will be trapped. Set the jars around the house, especially near any produce or around drains. Put more vinegar in the jar every few days, as the gnats are attracted to the smell. The gnats will die in the jar, so be sure to empty the jar as it gets full.
The Vinegar Institute suggests a mixture of 2 tbsp cider vinegar, 1 tbsp sugar, and a couple drops of dish soap in a quart of water. Setting this mixture around the house will draw the gnats.
Gnats are usually found around ripened produce, garbage disposals, or trash. Once they get into a home, they can be difficult to control. Keeping surfaces and floors clean of food particles in important, as well as making sure that the garbage disposal is run frequently. Any trash containing food should be emptied daily.