【发布时间】:2015-06-05 23:47:07
【问题描述】:
所以我正在尝试为 Sublime Text 3 编写一个 sn-p,用于在对象上调用的 forEach 语句。
//what I have written at the point where the snippet is triggered
myObject.forEa
// what should appear after triggering the snippet
Array.prototype.forEach.call(myObject, function(){
})
这里的问题是在sn-p的正则表达式中捕获myObject,这样我在写sn-p的时候就可以复用了。
到目前为止,我有一个正则表达式可以捕获任何适合我需要的 myObject:(\w|\.)+\b\.。但我需要准确捕捉光标之前的那个。
还可以使用一些环境变量,比如光标所在行的内容、光标的水平位置……Official documentation for snippets in Sublime Text。
可以吗?
【问题讨论】:
标签: regex sublimetext3 sublimetext