Vanity has several similar meanings translated from the following words in the King James Version:
2 Kings 17:15 - Vanity = hebel, a breath, means insubstantial, worthless and refers to idols in this passage. This is the word translated "Vanity" throughout the book of Ecclesiastes.
Job 15:31 - Vanity = shav, emptiness, worthlessness, lying
Job 15:35 - Vanity = aven, to pant, gasp, to exert oneself for nothing, trouble, wickedness, sorrow
Isaiah 40:17 - Vanity = tohu, formless, chaotic, empty, used here of the nations in God's estimation. Used in Genesis 1:2 "...the earth was without form" It is also used in Isaiah to describe the worthlessness of idols and idolatry - see 44:9.
Romans 8:20 - Vanity = mataiotes, devoid of truth, good for nothing, utterly inappropriate. Only other occurences are: Ephesians 4:17 and 2 Peter 2:18. These speak ofthe worthlessness of the Godless way of life and the lying words of false teachers.
The Old Testament references do not constitute a comprehensive list just samples of each word translated "vanity" in the KJV. In the New Testament, the word translated "vanity" occurs only in the verses cited.
I hope you have found this helpful.
May God bless you,
Mike