hashivim/vim-terraform

Saved .tf file is messed up with regards to tabs and space

madchap opened this issue · 7 comments

Hi,

When using the plugin, doing a <tab> seems to translate to a <space>. However, looking at the file without the plugin, we see that it was not written like that; <tab> are <tab>, and it is nasty.

It seems then the plugin is only doing a visual thing.

Is that by design?

Thank you.

Can you show me what you're seeing please with specifically the following ~/.vimrc (1)

set nu
set ruler
set list
set listchars=eol:⏎,tab:▶·,trail:.,nbsp:.,extends:\#

then again with (2)

execute pathogen#infect()
set nu
set ruler
set list
set listchars=eol:⏎,tab:▶·,trail:.,nbsp:.,extends:\#
let g:terraform_align=0
let g:terraform_fmt_on_save=0

and finally with (3)

execute pathogen#infect()
set nu
set ruler
set list
set listchars=eol:⏎,tab:▶·,trail:.,nbsp:.,extends:\#
let g:terraform_align=1
let g:terraform_fmt_on_save=1

(1)
tf-no-vimrc-with-tfsyntax

(2)
tf-align-off

(3)
tf-align-on

Will do as soon as I have a second... meanwhile, I can provide my current vimrc: https://github.com/madchap/dotfiles/blob/master/dotfiles/vimrc

Hi,

Only pasting 1 screenshot, as all results look alike after re-sourcing vimrc and reloading file? (not using pathogen, removed that command out, it gave an error anyway).

The piece below is one that really got the tabs messed, as I guess we can see with the many tabs symbols. The end results through a cat look like this:

image

With .vimrc 1, 2 and 3 looking the exactly the same:

image

So my original thought is: why aren't tabs just converted to spaces like it seems to be the best practice nowadays?

I realized I was missing the basic expandtab setup line in my vimrc, so I added this:

set tabstop=4 shiftwidth=4 expandtab and :retab the file.

After touching up on a few places, it seems to behave as expected.

The mistake was clearly on my side. Sorry about the noise, and thanks for looking at it anyways.

Have a good 2019.