简体   繁体   English

如何在vim脚本中获取光标下的单词和当前行的文本?

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

I'm trying to write a vim script. 我正在尝试编写vim脚本。 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. 我想在脚本中使用它,谢谢。

You can with expand and getline : 您可以使用expandgetline

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM