I am using the code getline(".")[col(".")-1] to get the character under the cursor. How can I check if the character under the cursor is a tab ?

1 Answer 1


Just compare the character you got with a tab, which can be represented with the \t escape sequence. That is,

getline(".")[col(".")-1] == "\t"

The expression will return 1 if the character is tab, 0 if not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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