5

How to count the number of whitespace in the beginning of a line ( aka indentation ). eg:

foo()
    foo()

And then

:command(2)
4
11

so easy i'm ashamed.

:echo indent(2)
  • 6
    And you can use :echo indent('.') / &shiftwidth to get the indent width of the current line (that's what . refers to) divided by the shiftwidth to get the indentation level. – Martin Tournoij May 15 '15 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.