I work on a variety of projects and many of them set file-specific vim settings. I have been asked to not have modelines set in .vimrc; is there a way after loading the file to load the modelines settings?
So if I open tmp.c with vim:
int main(int argc, char* argv[]) {
return 0;
}
/* vim: set expandtab tabstop=4 : */
Is there a command I can run to set the stuff in the modeline? Just doing :set modeline
after it is open doesn't do anything.
After :set modeline
, reload your buffer with :e
.
If you do not want to reload the buffer (e.g. because it contains unpersisted changes, or to avoid clearing the undo history), you can use the fact that a :doautocmd
triggers modeline processing:
:set modeline | doautocmd BufRead
You can tell vim to execute arbitrary commands before sourcing your ~/.vimrc
:
$ vim --cmd "set modeline" yourfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With