After reading usr_43 in VIM manual, I created ~/.vim/ftplugin
The manual said to check my runtimepath, the result
runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
Is the ftplugin under the runtimepath, or do I need to add ‘~/.vim/ftplugin’ into the runtimepath?
And then I tried to detect sql3 files:
vim ~/.vim/ftplugin/sqlte3.vim
if exists("b:did_ftplugin")
echo "yes : did_ftpplugin"
finish
elseif
echo "no : did_ftplugin"
endif
let b:did_ftplugin = 1
if did_filetype()
echo "yes : did_filetype"
finish
elseif
echo "no : do file type"
endif
if getline(1) =~ '^#!*[/\\]sqlite3\>'
setf sql3
echo "sqlite3 file"
elseif
echo "not sqlite3 file"
endif
after that I did ‘vim ~/test.sql3’
I thought to get some output to verify my workflow, but I get nothing.
How do I get the output from ~/.vim/ftplugin/sqlte3.vim?
Filetype plugin is a wrong place to put code like
What you should do is to add this to
ftdetect/sql3.vim:. Also note that if you want to have
sql3filetype, then ftplugin must also be namedsql3.vim, notsqlite3.vimlike in your example. Filename of ftdetect plugin does not really matter, this is just an agreement that for ftdetect files detecting one filetype their name should match detected filetype.