Loading filetype scripts when editing a file on VimEnter
"'John Jackson' via vim_use" <[email protected]> Mon, 1 Jun 2026 12:04:10 -0400
| Newsgroups | gmane.editors.vim |
|---|---|
| Message-ID | <[email protected]> |
Hello Vim users, I want an installation of gVim to auto-edit a "notes" file when opened=20 with no arguments. I'm using this script in my Vim configuration: vim9script def LoadNotes() =C2=A0 if argc() =3D=3D 0 =C2=A0 =C2=A0 edit path\to\notes.md =C2=A0 =C2=A0 echomsg "Auto-opened notes.md." =C2=A0 endif enddef autocmd VimEnter * ++once LoadNotes() This edits the file as expected. However, Vim does not apply syntax=20 highlighting to the file. When I run :scriptnames, none of the Markdown=20 ftplugin or syntax scripts are listed. (Although many other ftplugin=20 script names are listed.) If I manually run :edit after startup, then the syntax highlighting=20 works, and Vim's ftplugin\markdown.vim and its associated scripts are=20 now all listed in :scriptnames. Is there a way to guarantee that Vim will load all of the needed=20 filetype scripts during the VimEnter event? Or is there a more=20 appropriate event for this use case? I'm happy to provide more details=20 if they're helpful. :version VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Feb 14 2026 12:17:29) MS-Windows 64-bit GUI/console version with OLE support John --=20 --=20 You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php ---=20 You received this message because you are subscribed to the Google Groups "= vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_use/0fd= e278a-c7b1-4e57-8016-03a673adaf1f%40icloud.com.