Vim Text File Specific Settings
I have been trying to set Vim settings, specific for text files, in my .vimrc for the longest of time, and I really wanted to get this figured out this morning. So here we go.
It's all about the autocmd, or au, command, and you can set it up pretty easily. What I had in the past was:
autocmd FileType md \ set ai sw=2 sts=2 et autocmd FileType txt \ set ai sw=2 sts=2 et
where, in these two examples, I'm trying to set the autoindent to ON, the shiftwidth to 2, the softtabstop to 2 and expandtab to ON. And it wasn't working for files like goof.txt and for the life of me I could not figure this out.
And then it hit me - I had a FileType of javascript in the file, what if Vim needed to have text for the FileType? So let's try:
autocmd FileType markdown \ set ai sw=2 sts=2 et autocmd FileType text \ set ai sw=2 sts=2 et
And all of a sudden, it worked like a charm. I also tried markdown using the same reasoning. I guess that goes to show me that Vim is interpreting the file extension, and not literally using it as the FileType. Smart. Appreciated.