Try adding `:filetype detect` to the line after `edit`.
在2026年6月2日星期二 UTC+8 00:23:18<John Jackson> 写道:

> Hello Vim users,
>
> I want an installation of gVim to auto-edit a "notes" file when opened 
> with no arguments. I'm using this script in my Vim configuration:
>
> vim9script
> def LoadNotes()
>   if argc() == 0
>     edit path\to\notes.md
>     echomsg "Auto-opened notes.md."
>   endif
> enddef
> autocmd VimEnter * ++once LoadNotes()
>
> This edits the file as expected. However, Vim does not apply syntax 
> highlighting to the file. When I run :scriptnames, none of the Markdown 
> ftplugin or syntax scripts are listed. (Although many other ftplugin 
> script names are listed.)
>
> If I manually run :edit after startup, then the syntax highlighting 
> works, and Vim's ftplugin\markdown.vim and its associated scripts are 
> now all listed in :scriptnames.
>
> Is there a way to guarantee that Vim will load all of the needed 
> filetype scripts during the VimEnter event? Or is there a more 
> appropriate event for this use case? I'm happy to provide more details 
> 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
>
>

-- 
-- 
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

--- 
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 email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_use/3745a3e2-f3c3-4505-ad29-a78c004a3f8fn%40googlegroups.com.

Reply via email to