I want to write a custom fold-method file for .paul
files (based on the example at Learn Vimscript the Hard Way). However, it appears that my folding.vim
file is being ignored.
I'm running VIM version 8.2.1972 (on mac os 11.2.3)
~/.vimrc
contains nothing butsyntax on
~/.vim/filetype.vim
contains
" my filetype file
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.txt setfiletype txt
au! BufRead,BufNewFile *.paul setfiletype paul
augroup END
~/.vim/ftplugin/paul/folding.vim
contains
set foldmethod=expr
If I do vim sadf.paul
then :set ft?
returns filetype=paul
so the filetype detection is working.
However, :set foldmethod?
returns foldmethod=manual
, whereas I had expected to see foldmethod=expr
.
As a test, I then changed folding.vim to contain
set foldmethod=bogus
to see if I would get an error when the file was processed.
However, I see no error from the =bogus
statement in .vim/ftplugin/paul/folding.vim
, which makes me think that the file is never being sourced/run. And, per the suggestion from Christian Brabandt, running :scriptnames
confirms that ~/.vim/ftplugin/paul/folding.vim
was not sourced.
Any ideas what I'm doing wrong?
:scriptnames
if your file is actually being sourcedfiletype.vim
. Use ftdetect instead. 2. Must have at leastfiletype plugin on
.setlocal
for filetype plugins.:filetype
command, I bet you haveplugin:OFF
and that's what's causing the problem. You can fix that by addingfiletype plugin indent on
to your vimrc file. Or you can delete your vimrc file, which will make Vim load thedefaults.vim
file which enables that setting. (See:help defaults.vim
for more details. You can also explicitly loaddefaults.vim
from your vimrc, if you want more customizations.) Let me know if that solves the problem, in that case I'll post it as an answer. Cheers!