I know you can run a command upon entering a filetype with...

au! Filetype foo echo "bar"

but what can I use to run this command when I leave this filetype?

1 Answer 1


There's no such event as "leaving" FileType. It's just an option that could be set to another value effectively triggering yet another FileType event.

For user convenience, standard runtime supports buffer-locals b:undo_ftplugin and b:undo_indent to :execute them before new ftplugin/indent setting applied (provided that such variables exist). So they are used to undo anything done by the previous ftplugin/indent module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.