问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/25462500/how-to-know-from-which-line-a-script-is-called