I have tried the autocmd way, not work for me.
Press i at begin of the line, then press #, the # and cursor auto indent.
Press I at begin of the line, the cursor auto indent; then press #.
---------------------Edit------------------------
-
The first block and the second block bahaves different.
This drove me nuts too! Thankfully the solution is pretty simple:
autocmd FileType yaml,yaml.ansible setlocal indentkeys-=0#
You need to use "yaml.ansible" if you use the ansible-vim plugin. Using "setlocal" instead of "set" is optional but after decades with Vim I've learned that it is a good idea to specify local when you know you only want it local to avoid nasty surprises.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With