Discomfort with Zed's Indentation and the Melancholy of Meta Characters

5 min

language: ja bn en es hi pt ru zh-cn zh-tw

Image
Hello, this is Munou.
I tend to prefer using standard things in a standard way, so I don't like cluttering up my .vimrc. This makes the auto-indent feature for other languages quite difficult to manage. So, I recently started using Zed, but it feels strange.

What could it be...?

It feels significantly different from what I see when I open it with zeditor. Feeling uneasy, I investigated.

When I look with cat -A...

$ cat -A main.go 
package main$
$
import ($
^I"fmt"$
^I"net/http"$
^I"os"$
$
^I"golang.org/x/net/html"$
)$
$
func fetchOGP(url string) (siteName string, title string, err error) {$
^Iresp, err := http.Get(url)$
^Iif err != nil {$
^I^Ireturn "", "", fmt.Errorf("failed to fetch OGP URL: %w", err)$
^I}$
^Idefer resp.Body.Close()$
$
^Idoc, err := html.Parse(resp.Body)$
^Iif err != nil {$
^I^Ireturn "", "", fmt.Errorf("failed to parse HTML: %w", err)$
^I}$
$
^Ivar findOGP func(*html.Node)$
^IfindOGP = func(n *html.Node) {$
^I^Iif n.Type == html.ElementNode && n.Data == "meta" {$
^I^I^Ivar property, content string$
^I^I^Ifor _, attr := range n.Attr {$
^I^I^I^Iif attr.Key == "property" {$
^I^I^I^I^Iproperty = attr.Val$
^I^I^I^I} else if attr.Key == "content" {$
^I^I^I^I^Icontent = attr.Val$
^I^I^I^I}$
^I^I^I}$

Huh...?

It was hopeless, but I managed, however...

I'll try replacing it once and saving it again with Zed. So, I'll replace it once with...

sed "s/\t/  /g"

Then, after saving with Zed and trying cat -A again...

$ cat -A main.go 
package main$
$
import ($
^I"fmt"$
^I"net/http"$
^I"os"$
$
^I"golang.org/x/net/html"$
)$
$
func fetchOGP(url string) (siteName string, title string, err error) {$
^Iresp, err := http.Get(url)$
^Iif err != nil {$
^I^Ireturn "", "", fmt.Errorf("failed to fetch OGP URL: %w", err)$
^I}$
^Idefer resp.Body.Close()$
$
^Idoc, err := html.Parse(resp.Body)$
^Iif err != nil {$
^I^Ireturn "", "", fmt.Errorf("failed to parse HTML: %w", err)$
^I}$
$
^Ivar findOGP func(*html.Node)$

Aaaaaaaah!
There's no escape...

If you absolutely want to use 2-space indentation

It seems that doing :%s/\t/ /g in vim mode on Zed and then :wq is meaningless.

Do I have to run sed -i "s/\t/ /g every time, or fork it and rebuild it completely for myself...?
By the way,
Indentation conversion #4291
An issue for conversion has been raised.
And, after globally replacing tab characters with sed once, and setting ~/.config/zed/settings.json to

  "useTabs": false,
  "hard_tabs": false,

If I set it like this, I can escape it for now.
However, import statements, where the formatter takes effect, inevitably become tab-indented.

Wait? What about my original personality of wanting to use standard things in a standard way?

I thought that go fmt would clean up the indentation, but this automatically becomes tab indentation.
If it's recommended by default, is it the height of folly to insist on 2-space indentation?

....
I'm starting not to care either way...
See you next time.
Best regards.

Related Posts