Skip to content

Instantly share code, notes, and snippets.

@cornet
Created December 7, 2021 18:53
Show Gist options
  • Save cornet/9c2d49b0effcca821df70e6fcd0af191 to your computer and use it in GitHub Desktop.
Save cornet/9c2d49b0effcca821df70e6fcd0af191 to your computer and use it in GitHub Desktop.

Summary

Buffer local auto commands only seem to work when the file is passed on the command line and not when opening a file in an existing session.

Similar behaviour is exhibited with buffer local map settings as well.

Tested in both vim 8.2.2029 and neovim 6 with the same result.

It's most likely that I'm mis-understanding something but here is what I expect.

Steps to Reproduce

  1. Create init.vim with only the following: au BufWritePost <buffer> echo "Hello World"
  2. Run vim -u init.vim
  3. :e a.txt
  4. :w

Expected Result

Hello World printed in the status line

Actual Result

Nothing printed.

However if I run vim -u init.vim a.txt then it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment