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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?