Vim folds for terraform

Working with folds in vim is one of the techniques that can literally boost our efficiency. By default vim does not recognize terraform resources. But we can fix that with a simple plugin.

As humans we are not very good at multitasking. We can only focus on one task at a time. In Terraform that means that we only write or edit one resource at a time. So it makes sense to get everything else out of our way.

No matter what kind of text we edit, it always has some kind of structure. The good thing about vim is that can recognize that structure. For Terraform there is a simple filetype plugin ( which adds folding to .tf files.

In addition to the folds itself it remaps to za (open/close fold). That remap is useful outside of .tf files as well so you might want to put it in your vimrc.

nnoremap <space> za