如何知道脚本从哪一行被调用? [英] How to know from which line a script is called?

查看:165
本文介绍了如何知道脚本从哪一行被调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



代码:

...
line 500
line 501 an< silent> 98.80.00& Files.Test\ single \:call Func('%')< CR>
line 502
etc

所需输出: 501



是否有可能?

解决方案

除了关于你真的需要这个吗?的问题之外,这里有一个技巧:

 foo 
bar
let a = 5
let a = 5
let a = 5
call Foo(search('very special string'))
let a = 5
让a = 5
好​​玩! Foo(callerLineNumber)
echo a:callerLineNumber
endf

这会打印行号调用Foo(search('very special string''))



在搜索模式中制作一个非常特殊的字符串。


I would like to know from which line a script is called.

Code:

...
line 500
line 501  an <silent> 98.80.00 &Files.Test\ single\     :call Func('%')<CR>
line 502
etc

desired output: 501

Is it possible?

解决方案

Apart from the question about "do you really need this?", here is a trick:

"foo
"bar
let a = 5
let a = 5
let a = 5
call  Foo(search('very special string'))
let a = 5
let a = 5
fun! Foo(callerLineNumber)
    echo a:callerLineNumber
endf

this will print the line number of line call Foo(search('"very special string"'))

well you have to make a "really special string" in search pattern.

这篇关于如何知道脚本从哪一行被调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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