I have expandtab set but the filetype plugin overwrites my settings
set expandtab in your vimrc
I believe it gets overwritten here:
./vim-go/ftplugin/asm.vim
15:setlocal noexpandtab
./vim-go/ftplugin/go.vim
19:setlocal noexpandtab
expandtab lets you use tab to fill out the spaces. Is there a reason why you had noexpandtab set on the syntax file?
Both gofmt and goimports use tabs for indentation. If you don't want vim-go to auto format Go code, you can let g:go_fmt_autosave=0 and let g:go_asmfmt_autosave=0.
But before you do that, you may want to read https://blog.golang.org/go-fmt-your-code.
@bhcleek I see I didn't realize this was convention from the formatter. Seems like people should be able to control this in their text editor though and then run go fmt via a pre commit hook. I could set up some after plugins to set the expandtab correctly. I guess it's just weird to me that the formatter would prefer tabs to spaces.
I understand your concern; lots of new gophers experience the same consternation at first. But to quote Rob Pike's Go Proverbs (https://go-proverbs.github.io), "gofmt's style is no one's favorite, yet gofmt's is everyone's favorite."
You don't need to setup any after plugins, just disable gofmt in your vimrc with let g:go_fmt_autosave=0.
but I still want it to format ;D
Hi @vito-c
As @bhcleek said, this is how files are formatted in Go land. vim-go tries to be %100 compatible with the overall Go philosophy. Thanks
I know, I know. We will never have spaces in vim-go since Elders of the Internet have already ruled on that.
But since programmers who use spaces earn more, are smarter and better looking there is still a hope.
I have read blog post Vim can have better tab characters for Golang and learned that all you need is one command
:set listchars=tab:\|\ ,trail:-,extends:>,precedes:<,nbsp:+.
Is there anybody working for an option to allow expandtab to work in vim-go?
I also want an option to allow expandtab to work in vim-go.
Most helpful comment
but I still want it to format ;D