带有R的旺盛Ctags [英] Exuberant Ctags with R

查看:81
本文介绍了带有R的旺盛Ctags的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有文档记录R与 ctags 一起使用? 这有用吗? 实施起来会很难吗?

Is there any documented use of ctags with R? Would this be useful? Would it be difficult to implement?

具体地说,我刚刚开始使用Vim. 能够在一个文件中编写R函数,在另一个文件(例如,Rnw文件,测试文件或其他脚本)中使用该函数,并能够使用Ctrl +]导航到该函数会很酷.来源.

Specifically, I've just started using Vim. It would be cool to be able to write an R function in one file, use the function in another file (e.g., an Rnw file, test file, or some other script), and be able to use Ctrl+] to navigate to the function source.

更新:此后,我偶然发现了

Update: I've since stumbled on the rtags function, although it suggests that it is emacs specific.

推荐答案

这是对Henrico答案的修改,可以通过将以下代码复制并粘贴到一个人的〜/.ctags文件中来实现. Henrico的代码不适用于缩进函数,但以下代码可以.

This is a modification of Henrico's answer, and may be implemented by copying and pasting the following code into one's ~/.ctags files. Henrico's code did not work for indented functions, but the following code does.

--langdef=R
--langmap=r:.R.r
--regex-R=/^[ \t]*"?([.A-Za-z][.A-Za-z0-9_]*)"?[ \t]*<-[ \t]function/\1/f,Functions/
--regex-R=/^"?([.A-Za-z][.A-Za-z0-9_]*)"?[ \t]*<-[ \t][^f][^u][^n][^c][^t][^i][^o][^n]/\1/g,GlobalVars/ 
--regex-R=/[ \t]"?([.A-Za-z][.A-Za-z0-9_]*)"?[ \t]*<-[ \t][^f][^u][^n][^c][^t][^i][^o][^n]/\1/v,FunctionVariables/

这允许使用ctags和函数识别变量.如果使用的是标签列表vim插件,则可以区分全局变量和其他变量.另外,如果您使用的是标签列表,则需要将以下内容粘贴到vimrc中.

This allows variables to be recognized with ctags as well as functions. If you're using the taglist vim addon, then, it allows you to distinguish between global variables and other variables. Also, if you're using taglist, then you will need to paste the following in your vimrc.

let tlist_r_settings = 'R;f:Functions;g:GlobalVariables;v:FunctionVariables'

这篇关于带有R的旺盛Ctags的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆