dpjhq00684 2014-01-14 22:43
浏览 49
已采纳

通常,如何在VIM中“定义”? 那我怎么用golang呢?

Two part question:

First, when using VIM what process do I take and what keys do I type to "go to definition" or "go to declaration" etc.? This document might be the answer to my question, but I can't get it to work, so I'm unsure. It looks like its merely text matching the string rather than finding the true definition. If I can get this to work, then will I be able to jump outside of the current document to a definition/declaration? Or does this only work within a single document?

Second, how do I make this work specifically with the Go programming language? It sure would be nice to "click" the Client in

clnt := &http.Client{Transport: tr}

And be taken to the actual code that defines an http.Client.

Possible? How?

  • 写回答

2条回答 默认 最新

  • doufeinai6081 2014-01-15 01:41
    关注

    As you guess, gd (and other commands) is merely text matching, vim don't understand the syntax as it is just a text editor, :h gd will explain how gd works.

    Usually, 'go to definition' is brought by using CTRL-] and tag files. A user manual about this topic can be read by :h 29.1.

    First you need to generate a tags file for your project, as latest Exuberant Ctags has supported golang (from here), command

    cd /path/to/your/project
    ctags -f tags -R --fields=+K+a
    

    will do the job.

    Second, open vim, by default vim will find tag files under working directory (according to 'tags' option), if the tag file is found successfully, then CTRL-] should works well.

    Also check two useful plugins Tagbar and Easytags.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统