There are a lot of words that basically means Chinese (language) and can usually be used interchangeably but do convey subtle differences in meaning and situations.
1.中文 (Chinese language)
The most popular one. Can be used in almost any situation.
- 中文听起来真好听。
- 新加坡说中文吗?
- 中文难写难认。
2.汉语 (Han Chinese language)
Prominent in academic and formal circumstances. Also used by people who prefer a more formal style.
- 汉语音韵悦耳。
- 新加坡使用汉语吗?
- 古代汉语
- X古代中文
- 学汉语,要听说读写兼顾。
But it is focused on the spoken part. When you are specifically referring to the written script, 汉字(Chinese characters) is used instead.
汉字 as a form of writing is also used in some other languages. In this sense, do not use 中文.
- 传统上,日语、朝鲜语和越南语也部分使用汉字书写。
- X传统上,日语、朝鲜语和越南语也部分使用中文书写。
3.国语 (National language), 华语 (Hua language), 普通话 (Common Tongue)
All the same thing, namely Mandarin (官话), but used by different people. 国语 is used in the Republic of China (Taiwan), 华语 in Southeast Asia by ethnic Chinese immigrants, and 普通话 in the Republic of China (mainland China). They are as different as Received Pronunciation and General American Accent are.
On the other hand, 中文 and 汉语 includes 粤语 (Cantonese) and other dialects of Chinese(some would say they are languages in the Chinese language family).