Find what filetype is loaded in vim

前端 未结 5 863
旧巷少年郎
旧巷少年郎 2021-01-29 19:09

As soon as I load any file in vim, It\'ll try to detect the file and color-highlight it if possible.

I want to know a vim command that will tell me which ftplugin or Fil

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-29 19:29

    &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

提交回复
热议问题