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