Reputation: 1509
I'm writing a Vim script. How can I get the word under the cursor and the text of the current line?
Upvotes: 55
Views: 14831
Reputation: 828200
You can with expand and getline:
let wordUnderCursor = expand("<cword>")
let currentLine = getline(".")
Upvotes: 79