Find what filetype is loaded in vim

Solution 1:

:set filetype?

Solution 2:

&filetype for script usage

Minimal example:

echo &filetype

More realistic usage example:

if &filetype ==# 'c' || &filetype ==# 'cpp'
  setlocal noexpandtab
endif

& syntax works for all options: https://vi.stackexchange.com/questions/2569/how-do-i-check-the-value-of-a-vim-option-in-vimscript