doujiao1538 2016-06-24 10:07
浏览 120
已采纳

在vim中禁用gofmt-在vim ide中插入

How can i disable gofmt in vim-plug ide for vim?

Hello, I'm using vim-plug as my vim based IDE for golang. I've a very specific query. I don't want gofmt to do any unnecessary formatting for my code. I raised an issue with vim-plug on github but I was suggested that the issue is with vim-go.

I've my own set tabstop=4 in my .vimrc. I add header section to .go sources to help the reader understand what exactly the source file is all about. At many places in the code, additionally, I add more than 1 line in the code for cleaner segregation. Earlier, gofmt was modifying everything while saving a file.

By including following 2 lines in my .vimrc

let g:go_fmt_fail_silently = 1
let g:go_fmt_autosave = 0
I've gotten rid of unnecessary errors and formatting by gofmt to my .go 

source files, respectively.

However, I'm not being able to disable gofmt from adding 8-space tab. Since I have my own 4-space tab, I don't want those 8-charater tabs added by gofmt.

So, I want to disable gofmt at all. Can someone please help me to disable gofmt?

Version information: I use vim-7.4 on CentOS 7.2

Regards, - sameer oak.

  • 写回答

1条回答 默认 最新

  • douyu2817 2016-06-24 11:02
    关注

    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.

    You really should reconsider fighting against gofmt, It will make reading the code much easier for anyone with Go experience.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭