tofu/terraform fmt in vim

I like to mainly work in Vim instead of a full blown editor like VSCode. One thing I missed was a plugin that would automatically run tofu fmt (or terraform fmt) on files when you saved them. I added this to my ~/.vimrc which does the same thing now. Anytime a file with either *.tf or *.tfvars is saved in the buffer a tofu fmt is run on it first.

" run tofu fmt everytime you save a file
autocmd BufWritePost *.tf :silent !tofu fmt %
autocmd BufWritePost *.tfvars :silent !tofu fmt %

You'll only receive email when they publish something new.

More from highteklowlife
All posts