And I add this in the vimrc file:

autocmd FileType markdown iabbrev mkdc <!--i--><left><left><left>

What I want to do is source the vimrc and make the abbreviation effective for the current file I'm editing.

I have tried:

  1. :!sc, :redraw!
  2. :source $MYVIMRC
  3. :q and rerun Vim

But it seems that only the last method works. Is there any way to get this to work without leaving Vim? Why doesn't the second method as stated in all other related answers work in this situation?

  • 1
    Possible duplicate of How do I reload my vimrc without leaving Vim?
    – Tumbler41
    Aug 25, 2016 at 0:35
  • Yeah, but maybe my problem is not the same as that one since I've tried the methods in those answers. Aug 25, 2016 at 0:39
  • Try #2 after starting vim with vim -u NONE. Odds are there's either something in your vimrc or plugins that's messing with it.
    – Tumbler41
    Aug 25, 2016 at 0:43

2 Answers 2


Your autocommand is executed when the FileType event is triggered, with the markdown value. Sourcing your vimrc is not enough because it only adds the autocommand but the event is not triggered.

What you need to do is:

  1. Source your vimrc with :source $MYVIMRC, this will add your autocommand to the existing ones.
  2. Reload your current buffer with :e, this will trigger the FileType event and thus run your autocommand.

Also, adding half-understood FileType autocommands to your vimrc is not a good way to get filetype-specific settings/mappings/abbreviations/commands/whatever.

Instead, you should use the built-in filetype detection and put your filetype-specific stuff in proper ftplugins:

  • in ~/.vimrc:

    filetype plugin indent on
  • in ~/after/ftplugin/markdown.vim:

    iabbrev <buffer> mkdc <!--i--><left><left><left>

command! Sov source $MYVIMRC | e %


  • 6
    Welcome to Vi and Vim! In general, good answers provide not just code snippets, but explanations of what the code does and how to use it, as well as why it's needed.
    – D. Ben Knoble
    Apr 10, 2020 at 20:57

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.