A tert-butyldiphenylsilyl-containing polyimide (PI-OSi) has been established as a colorimetric and ratiometric chemosensor for rapid detecting fluoride ions (F−). The UV-vis absorbance ratio value (A322/A288) of PI-OSi in a DMF solution displays a wide linear range change to F− concentrations with a detection limit (DL) value of 2.13 μM. Additionally, adding incremental amounts of F− to a DMF solution of PI-OSi shows an immediate color change to yellow and finally to green from colorless. More interestingly, the resulting PI-OSi plus F− system (PI-OSi·F) could detect trace water in DMF. The A292/A322 value of PI-OSi·F almost linearly increases with low water content, which suggests convenient quantitative sensing of trace water content in DMF. The DL value of PI-OSi·F for sensing water in DMF is determined to be 0.00149% (v/v). The solution color of PI-OSi·F returns to colorless when the water content increases, indicating that PI-OSi·F can conveniently estimate water content in DMF by naked-eye detection. The detection mechanisms confirmed by an 1H NMR study and a DFT calculation involve a F−-induced desilylation reaction of PI-OSi to form phenolate anion followed by protonation with trace water. Finally, PI-OSi film was fabricated for the colorimetric detection of F− and water in CH3CN.