Vim 有 expand("<cword>")
获取光标下的“单词”。如果光标位于带引号的字符串文字上,您将如何定义一个函数来获取引号之间的所有内容?
考虑到这种情况:
foo = "this string has spaces" ^ cursor is here
I want to do
:echo GetStringUnderCursor()
看看
this string has spaces
EDIT: I see you can check if the cursor is on a string region with this incantation
synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name") == "String"
我只是还没有找到一种方法来查找给定语法区域的开始和结束位置(行和列)。
最佳答案
例如:
vi" -> visual select all inside the quotes
ci" -> change all inside the quotes
yi" -> yank all inside the quotes
如果你猛拉它,你可以这样做:
echo @" -> prints register " (default)
关于vim - 获取光标下的整个字符串文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12964573/