使用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.
Run Code Online (Sandbox Code Playgroud)