zoukankan      html  css  js  c++  java
  • win下gosublime配置ctag

    ctags(Generate tag files for source code)是vim下方便代码阅读的工具。尽管ctags也可以支持其它编辑器,但是它正式支持的只有VIM。并且VIM中已经默认安装了Ctags,它可以帮助程序员很容易地浏览源代码。

    参考:

    http://baike.baidu.com/view/9340968.htm

     

     

    环境准备:

    1、安装 sublimetext  3

    下载安装最新版本  sublimetext 3     http://www.sublimetext.com/3 

     

    2、安装 Package Control,

    在打开 Sublime Text 3以后,按下快捷键 Ctrl + `或者到菜单栏的:View > Show Console执行以下命令
    import urllib.request as urllib2,os;pf=‘Package Control.sublime-package’;ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),’wb’).write(urllib2.urlopen(‘http://sublime.wbond.net/'+pf.replace(‘ ‘,’%20’)).read())

    //下面的是ubuntu的
    import urllib2,os; pf=‘Package Control.sublime-package’; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),’wb’).write(urllib2.urlopen(‘http://sublime.wbond.net/'+pf.replace(‘ ‘,’%20’)).read()); print ‘Please restart Sublime Text to finish installation’

    Mac下命令如下:

    import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

    参考:http://jinzhe.net/post/16.html

     

    3、安装 GoSublime

    Command+Shift+P 打开Package Control ,然后输入 pcip (即“Package Control: Install Package”的缩写)
    在随后出现的界面输入GoSublime,点击出现的项,就可以成功安装GoSublime了。

     

    4、go fmt启用:
    选中sublime text菜单栏的Perferences>Package Settings>GoSublime>Settings User
    找到env,并设置成:”env”: { “PATH”: “$HOME/go/bin:$PATH”},“use_gs_gopath”: true,

     

    安装 ctag

    4.1.下载并解压ctags包中的ctags.exe放到任何目录下面,然后把这个目录添加到系统的环境变量PATH里面,最简单就是放在 C:WindowsSystem32 目录下。

    下载地址: http://ctags.sourceforge.net/

    mac下安装方法:

    The default ctags executable in OSX does not support recursive directory search (i.e. ctags -R). To get a proper copy of ctags, use one of the following options:

    Ensure that the PATH is updated so the correct version is run:

    • If which ctags doesn't point at ctags in /usr/local/bin, make sure you add /usr/local/bin to your PATH ahead of the folder which ctags reported.
    • Alternatively, add the path to the new ctags executable to the settings, under command. If you have Xcode / Apple Developer Tools installed this path will likely be /usr/local/bin/ctags.

     

    4.2 安装 sublime text 的 Ctags 插件。

    官方说明文档地址: https://github.com/SublimeText/CTags 

    image

    官方Windows的安装说明如下:
    • Download the CTags binary from the Exuberant CTags site.
    • Extract ctags.exe from the downloaded zip to C:Program FilesSublime Text 2 or any folder within your PATH so that Sublime Text can run it.
    • Alternatively, extract to any folder and add the path to this folder to the command setting.

    安装结束之后,重启Sublime Text之后,打开$GOROOT/pkg文件夹,

    其中$GOROOT就是Go的安装目录,比如默认的是C:go。打开之后,点击pkg节点,右键,选择CTags: Rebuild Tags

    image

    等待运行完成后,我们就可以做跳转了,在函数上按ctrl+shift+鼠标左键, 就可以看到跳转。

     

    CTags: Rebuild Tags 这一步其实是在 pkg 目录下执行下面命令:

    ctags -R -f .tags的命令

     

    image

     

    sublime text 导入工程

    project->add folder to project,选择要导入的文件。

    参考资料:
    http://blog.csdn.net/laukaka/article/details/9737815

     

    参考资料:

    http://golanghome.com/post/126

     

    Sublime Text 的Ctag 的默认命令快捷键如下:

    参看: https://github.com/SublimeText/CTags 

     

    官方提供的快捷键如下:

    image

    不过我在 Windows 下试验有效的是下面2个,其他都没有试用通过:

    调转到定义:  ctrl + shift + left_click

    跳转回来: alt + -  (当前打开页面的光标回来)

    参考: http://golanghome.com/post/477

     

    ubuntu 下搭建请参考: http://golanger.cn/sublime-text-2%E4%BD%BF%E7%94%A8ctags%E5%AE%9E%E7%8E%B0%E5%87%BD%E6%95%B0%E8%B7%B3%E8%BD%AC/

  • 相关阅读:
    BestCoder6 1002 Goffi and Squary Partition(hdu 4982) 解题报告
    codeforces 31C Schedule 解题报告
    codeforces 462C Appleman and Toastman 解题报告
    codeforces 460C. Present 解题报告
    BestCoder3 1002 BestCoder Sequence(hdu 4908) 解题报告
    BestCoder3 1001 Task schedule(hdu 4907) 解题报告
    poj 1195 Mobile phones 解题报告
    二维树状数组 探索进行中
    codeforces 460B Little Dima and Equation 解题报告
    通过Sql语句控制SQLite数据库增删改查
  • 原文地址:https://www.cnblogs.com/ghj1976/p/4318421.html
Copyright © 2011-2022 走看看