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 onto my vimrc file.The
:filetypecommand returns:filetype detection:ON plugin:ON indent:ON.I then created a filetype file called
project.vimin a new directory calledftdetectin the first item ofruntimepath(~/vimfiles).In the
project.vimfile I added the autocommand line to enable filetype detection:au BufNewFile,BufRead *project setf projectI then created a filetype plugin file called
project.vimin a new directory calledftpluginin the first item ofruntimepath(~/vimfiles). In that file I added the following setlocal options for comments:setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croqlAs neither the directory
ftdetectorftpluginwere appearing in the output of:set runtimepath?, I added this line to my vimrc:set rtp+=~/vimfiles/ftdetect,~/vimfiles/ftpluginAfter 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/ftpluginI then created a test file with the
projectfiletype 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=confthe comments appear as expected. The filetype file for 'conf' has identicalsetlocaloptions for comments.I added a
setlocaloption for a statusline to~/vimfiles/ftplugin/project.vim. The corresponding statusline became present in the test file. Running the:set ft?command indicated returnedfiletype=projectas before.I am a now a bit stuck and would welcome any help.
(6) and (7) are unneeded and useless. Only "vimfiles" must be in runtimepath. "ftdetect" and "ftplugin" are always taken relative to it.
(8) Syntax does not have anything to do with options you set. Instead, you have to create regexes and enable syntax support. How to do it is a topic of its own, so you're adviced to start long reading at
:h syntaxand all such.