chausies
chausies

Reputation: 854

How to get the column of the beginning of a line in vim script

In vim script, col("$") will return the column # of the end of the line. I want something similar to get the column # for the beginning of the line, something like col("^"). But that doesn't work, nor can I find anything that does that.

I want this so that I know the amount of white-space at the beginning of a line.

Upvotes: 3

Views: 465

Answers (2)

ryuichiro
ryuichiro

Reputation: 3875

Do you mean something like this?

indent(line("."))

Upvotes: 6

chausies
chausies

Reputation: 854

The best I can come up with right now to do this is

normal! ^
col(".")

That's not an ideal solution, though, because I'm essentially just moving the cursor where I want and then checking the column.

Upvotes: 0

Related Questions