I'm using Vim 9.0 on Windows 10.
I've created a new filetype called 'projects' but setting local options for comments is not working. Here is what I've done:
I added the line
:filetype plugin indent on
to my vimrc file.The
:filetype
command returns:filetype detection:ON plugin:ON indent:ON
.I then created a filetype file called
project.vim
in a new directory calledftdetect
in the first item ofruntimepath
(~/vimfiles
).In the
project.vim
file I added the autocommand line to enable filetype detection:au BufNewFile,BufRead *project setf project
I then created a filetype plugin file called
project.vim
in a new directory calledftplugin
in the first item ofruntimepath
(~/vimfiles). In that file I added the following setlocal options for comments:setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
As neither the directory
ftdetect
orftplugin
were appearing in the output of:set runtimepath?
, I added this line to my vimrc:set rtp+=~/vimfiles/ftdetect,~/vimfiles/ftplugin
After I did this the output of
:set runtimepath?
included those previously missing directories as the last listed items:runtimepath= ~/vimfiles, ~\vimfiles\pack\plugins\start\VOoM, ~\vimfiles\pack\plugins\start\vimroom, ~\vimfiles\pack\plugins\start\vim-shell-master, ~\vimfiles\pack\plugins\start\vim-obsession-master, ~\vimfiles\pack\plugins\start\vim-misc-master, ~\vimfiles\pack\plugins\start\vim-addon-mw-utils, ~\vimfiles\pack\plugins\start\utl, ~\vimfiles\pack\plugins\start\tlib_vim, ~\vimfiles\pack\plugins\start\taskpaper.vim-master, ~\vimfiles\pack\plugins\start\tabular, ~\vimfiles\pack\plugins\start\supertab, ~\vimfiles\pack\plugins\start\limelight, ~\vimfiles\pack\plugins\start\goyo, ~\vimfiles\pack\plugins\start\ctrlpcache, ~\vimfiles\pack\plugins\start\ctrlp, C:\Program Files (x86)\Vim/vimfiles, C:\Program Files (x86)\Vim\vim90, ~\vimfiles\pack\plugins\start\tabular\after, C:\Program Files (x86)\Vim/vimfiles/after, ~/vimfiles/after, ~/vimfiles/ftdetect, ~/vimfiles/ftplugin
I then created a test file with the
project
filetype extension and entered some text, but it was not commented as per the setlocal option (ie: the text in lines prepended with#
should be italicized).I ran the command
:set ft?
on the test file, which returnedfiletype=project
. When I change the filetype toset ft=conf
the comments appear as expected. The filetype file for 'conf' has identicalsetlocal
options for comments.I added a
setlocal
option for a statusline to~/vimfiles/ftplugin/project.vim
. The corresponding statusline became present in the test file. Running the:set ft?
command indicated returnedfiletype=project
as before.I am a now a bit stuck and would welcome any help.