How can I get the word under the cursor and the text of the current line in vim script? May 3, 2023 by Tarik You can with expand and getline: let wordUnderCursor = expand("<cword>") let currentLine = getline(".")