Mike
unread,Oct 1, 2026, 10:41:59 PM (4 days ago) Oct 1Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim...@googlegroups.com
Hi all,
I'm seeing unexpected behavior when using an autocmd defined in a
plugin. A simplified version of the plugin is the following:
function! InsertText()
echomsg "modified option is " .. &modified
call append(line("$"), "section title")
echomsg "modified option is " .. &modified
endfunction
autocmd FileType fortran call InsertText()
command -nargs=0 ForNoFT call InsertText()
It's purpose is to automatically insert lines in files that have a
specified filetype or to provide that service for other files. In the
above example, I've used "fortran" but I think any vim-recognized
filetype will do.
To show the problem, edit a Fortran file, e.g. run "vim test.f90". You
will see the text "section title" in the buffer. However, even though
the 'modified' option is set, I am allowed to quit vim (:q). Also, ^G
does not show modified. This behavior occurs whether the file
"test.f90" is new or has content.
A user-command has been defined in the plugin, intended for files
without a filetype. When you run "vim test.unknown" and then run the
user-command "ForNoFT", quit will fail as expected and ^G will show
modified.
Interestingly, if 'modified' is explicitly set in the function, then vim
will not quit because it sees test.f90 as modified.
My question is why the difference?
I'm running vim 9.2.1036 with normal features on Windows 10.
Thanks for any help.
-mike