如何在vim脚本中获取光标下的单词和当前行的文本? [英] How can I get the word under the cursor and the text of the current line in vim script?

查看:31
本文介绍了如何在vim脚本中获取光标下的单词和当前行的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 vim 脚本.如何获取光标下的单词和当前行的文本?我想在我的脚本中使用它,谢谢.

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.

推荐答案

你可以用 展开getline:>

You can with expand and getline:

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

这篇关于如何在vim脚本中获取光标下的单词和当前行的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆