Say I am writing a plugin and constantly editing scripts in ftplugin. How do I efficiently test the changes? I can't simply source the editted file because they are filetype-specific. For example, if there is a lineset buftype=nofilein the script, and I source it, then whatever buffer I'm in will no longer be writable into a file...I can open another vim instance to test the change, but that is not very efficient because I have to reopen one whenever I make changes to the ftplugin scripts.
How do I test ftplugin scripts efficiently
vimscript;filetype
Add this to your script:let b:undo_ftplugin='setlocal buftype='When the FileType autocmd is fired, that variable will execute.  To trigger the autocmd, you could run :set ft=whatever to reload the ftplugin and syntax scripts.While I'm tweaking an ftplugin, I usually don't want to save the changes made in a buffer during testing.  So, I just use :e! to reload the buffer since :edit effectively sets the detected filetype.You can read more about this in :h undo_ftplugin.  To see exactly how this works, you can look at the script that loads your ftplugin script::e $VIMRUNTIME/ftplugin.vim