Please don't. You are free to use in your editor whatever settings you desire,
but please don't change gofmt default behavior. In fact, I'm not sure why
gofmt even has configurable options. Its point is to fix formatting
once and for all.
--
Aram Hăvărneanu
> The vim plugins in Go work fine, but I personally prefer 4 spaces
> indent per level instead of a tab every 8th column. Of course, I could
> configure vim with ":set ts=4" but problems occur e.g. when copy-
> pasting part of the listing to
> some text processor.
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:
>
> - in vim/ftplugin/go/fmt.vim, line 20: change "%!gofmt" to "%!gofmt -
> tabindent=false -tabwidth=4"
> - in vim/syntax/go.vim, line 32: insert "set sw=4"
>
> That´s all; it would be nice to make it configurable in one central
> place - what are your opinions?
Nope, not going to happen. You're free to change your own tabwidth,
but we're not going to make it easy for people to not use tabs.
There's one Go style.
> There is one problem left I could not solve. The "classic" C comment /
> * ... */ over several lines are only indented and completed right for
> the cindent option which is switched off deliberately. I am afraid
> that a solution in vim script language would not be so easy (the
> feature is hardcoded in vim), but I haven´t tried it yet. Would it not
> be nice to
> have this feature in gofmt? (Though writing with automatic indent of
> "*" and inserting a space after is more
> comfortable).
It honestly doesn't come up much. I don't think I've seen much Go code
at all that uses a line of stars for the /* */ style of comments; it's
either
/*
Some text
over lots of
lines.
*/
or
// Some text
// over lots of
// lines.
both of which are handled fine by vim.
Dave.
>> Nope, not going to happen. You're free to change your own tabwidth,
>> but we're not going to make it easy for people to not use tabs.
>> There's one Go style.
>
> I'm all for pride of authorship but I find this type of comment off-
> putting. I've seen a sort of "do it the Go way or don't do it"
> attitude a few times in the forums and it always makes me cringe a
> bit.
>
> Tabs especially have been a contentious subject for at least the time
> I've been programming. It's a real issue for those of us who have
> large fonts and poorer eyesight. Tabs don't work consistently across
> all editors and screens! Spaces do for me.
This is the whole point. There's been so much historic to-and-fro over
something that matters much less than people think. Pushing one
automated code layout style avoids people quibbling over such small
matters so we can spend time on more important things.
Good editors allow you to set how many spaces a tab character will be
rendered as. You're perfectly free to set your editor up to have a tab
width of two spaces, and then it's visually indistinguishable from
indenting with two space characters. If your editor doesn't make that
configurable, you should get a better editor.
Dave.
Search the mailing list and you'll see this discussion has been done to
death. Search the Internet and notice that every mailing list for every
project ever has this discussion and it's completely pointless.
For Go a decision was made on a style. It may not be exactly what you
like, but everyone else uses it and a consistent style across everyone
using the language increases readability far more than any one's
individual stylistic preferences.
If your screen or editor can't even handle tabs (stuck in the 70's?)
it's very doubtful it could handle utf-8 and thus isn't useful for
editing Go code.
I'd be happy if the gofmt style was part of the language spec and the
compilers actually enforced it.
- jessta
On Fri, 23 Dec 2011 12:46:38 -0800 (PST)
Reinhard <zwi...@gmx.de> wrote:
> The vim plugins in Go work fine, but I personally prefer 4 spaces
> indent per level instead of a tab every 8th column. Of course, I could
> configure vim with ":set ts=4" but problems occur e.g. when copy-
> pasting part of the listing to
> some text processor.
>
> It is quite easy to change the default:
>
> - in vim/ftplugin/go/fmt.vim, line 20: change "%!gofmt" to "%!gofmt -
> tabindent=false -tabwidth=4"
> - in vim/syntax/go.vim, line 32: insert "set sw=4"
>
> That´s all; it would be nice to make it configurable in one central
> place - what are your opinions?
I don't like the tabs either. The way I handle them is using a tiny
shell script in a file called 'gf':
#!/bin/bash
gofmt -s=1 -tabwidth=4 -tabs=false $*
I then reformat within vim using :'<,'>!gf or :%gf which aren't too
much to type.
--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Programming in Go" - ISBN 0321774639
http://www.qtrac.eu/gobook.html
I don't like the tabs either. The way I handle them is using a tinyshell script in a file called 'gf':
#!/bin/bash
gofmt -s=1 -tabwidth=4 -tabs=false $*
This is in principle the better way. However, it is based on the fact
that autocommands are stacked, and .vimrc is executed before all
plugins which then use sw.
I personally prefer a local setting in e.g. .vim/after/syntax or .vim//
ftdetect/ since then it is clearer what happens (in my case, I am
alone on my computer).
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.