WebDec 23, 2011 · The solution there is simply to run gofmt on the buffer after pasting. If you're using the full set of vim plugins in the tree, :Fmt will do that. > It is quite easy to change the default: > > -... WebThe gofmt program (also available as go fmt, which operates at the package level rather than source file level) reads a Go program and emits the source in a standard style of indentation and vertical alignment, retaining and if necessary reformatting comments. ... Indentation We use tabs for indentation and gofmt emits them by default.
Why does gofmt by default use an 8 space indent? - Google …
WebApr 1, 2024 · gofmt-args's type is a list of strings, so that is what you need to give it. You can set it like this: (setq gofmt-args '("-tabs=false" "-tabwidth=2" "-w=true")) If you are setting it interactively, its probably easiest to use M-x customize-variable RET gofmt-args RET. That will give you an interactive UI for adding and removing elements from ... WebJun 24, 2016 · Instead of disabling gofmt, you could make it work how you expect. This answer about tabs/spaces will be useful. You need to set shiftwidth=4 so that tab indents appear to be the same size as tabs. There are no 8 space tabs vs 4 space tabs (tabs don't have a width, vim uses these setting to display the tab as 4 characters. ccyfl md
Ubuntu Manpage: gofmt - formats Go programs
WebJul 8, 2024 · Gofmt formats Go programs. It uses tabs (width = 8) for indentation and blanks for alignment. Original answer (deprecated): Formatting control flags: -comments … WebJan 16, 2024 · gofmt. With gofmt, you can format Go source code in the opened file or in the whole Go project. For a single file, you can use the built-in import management and … WebMar 29, 2024 · Note: if you add a comment that does not align with the code, the gofmt tool will fix that. This tool, provided with your Go installation, formats Go code (including comments) to a universal format so that Go code everywhere looks the same and programmers cannot argue over tabs and spaces. ccyfo