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 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问