I have a variety of vimscripts for different filetypes in ~/.vim/after/ftplugin
, e.g. text.vim
, vim.vim
, etc. These contain a variety of settings, mappings, etc. Only recently, I've noticed (not sure why it took me so long!) that these scripts get re-run, and the settings re-applied, every time I save the file. This is annoying, for example, if the vimscript runs set textwidth=78
, I then manually change the textwidth
and then save the file. Normally I want that setting to persist, at least for this editing session, but it's immediately changed back.
Is this expected behaviour? I think what might be happening here is that the files are re-run because the filetype detection logic is re-evaluated when I save the file.
Is there a standard pattern/approach to work around this behaviour? I looked at the help for runtimepath
but it didn't help much.
:e
, but not really when you write it... Can you try a simpler reproducer undervim --clean
or similar?:verbose set tw?
says? Is it really your ftplugin the culprit?