In vim-script, how would I go about reliably assigning to a variable the indentation for the current line?
curpos()
to get the col does not seem reliable, as it only counts spaces, and I would need to take into account the tabstops as well.
Use the indent()
function; from :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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With