Search code examples
vimdefaultnew-operatorfile-type

VIM: set filetype=txt for every new file [No Name]


I tried all possible things to let vim set filetype to 'txt' to all new files I create (in a new tab) but it doesn't work.

This is p.e. what I've read on the web a few times:
au BufRead,BufNewFile *.txt setlocal ft=txt
(to put in _vimrc)
However it doesn't work.

Can anyone help me?


Solution

  • The following line, added to your .vimrc, will set the filetype to text if it is not already set.

    autocmd BufEnter * if &filetype == "" | setlocal ft=text | endif