I have the following workflow:

  • Create a new unnamed buffer with :enew
  • Use a snippet to add a modeline to it. E.g. vim:tw=80:ft=text:spell

Once I've done that the modeline isn't applied and I can't do :e % to reload the buffer and apply the modeline since it is an unnamed buffer.

What can I do to apply the modeline in this unnamed buffer?

1 Answer 1


If you look at the :h auto-setting help file, you will see that the options are set on different occasions:

  1. At initialization
  2. On autocommands
  3. When starting editing the file with the modeline on

You can reload the modeline without actually reloading the buffer by calling manually an autocommand:

:doautocmd BufRead

This will reload your modeline without reloading your file.

Of course, you need to have set modeline prior to this (otherwise the modeline won't be used).

Reference: :h :doautocmd.

Note: if you want to actually execute an autocommand without reloading the modeline, you can pass the <nomodeline> to the doautocmd method.

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.