在 vim-script 中,我如何可靠地为变量分配当前行的缩进?
curpos()
获取 col 似乎不可靠,因为它只计算空格,我还需要考虑tabstops。
答案 0 :(得分:5)
使用indent()
功能;来自:help indent()
:
indent({lnum}) The result is a Number, which is indent of line {lnum} in the
current buffer. The indent is counted in spaces, the value
of 'tabstop' is relevant. {lnum} is used just like in
getline().
When {lnum} is invalid -1 is returned.