
Nebulaworks Insight Content Card Background - Erik eastman shanghai architecture
Recent Updates

Terraform & Vim Plugin Basics
If you’ve been starting to write Terraform configuration inside of vim
then here are a
few tips of what you should enable to make life simpler when working with those *.tf files.
Installation
Taken directly from the vim-terraform git repo: Installation is as simple
as cloning the repo if you are leveraging pathogen.vim
:
cd ~/.vim/bundle
git clone https://github.com/hashivim/vim-terraform.git
Note: If you prefer to use something besides pathogen, go ahead.
Config
The most immediate change you should notice without any additional configuration is that syntax highlighting is now
enabled! If you want to set up a specific olorscheme for *.tf’s then specify it as follows (this assumes the
colorscheme icansee
is already installed):
autocmd BufEnter *.tf* colorscheme icansee
Terraform has a command called terraform fmt which is the canonical
format and style for *.tf files. What’s really slick is vim-terraform
allows automatically running terraform fmt
when saving *.tf and/or *.tfvars files. Its as simple as adding the following to your existing .vimrc
:
let g:terraform_fmt_on_save=1
Along with terraform fmt
I would recommend adding the override for indentation to your .vimrc
. This overrides the
indentation level to 2 spaces to conform to the hashicorp style:
let g:terraform_align=1
Note: Make sure you have a recent clone of the plugin since there was a bug in Sept which effected this option.
Conclusion
This should give you a very nice and consistent configuration to be able to work with terraform
inside of vim. Happy
Terraforming!

Looking for a partner with engineering prowess? We got you.
Learn how we've helped companies like yours.