How can I get the word under the cursor and the text of the current line in vim script?

Viewed 11146

I'm trying to write a vim script. How can I get the word under the cursor and the text of the current line? I want to use it in my script, thanks.

1 Answers

You can with expand and getline:

let wordUnderCursor = expand("<cword>")
let currentLine   = getline(".")
Related