Reputation: 11194
Vim has expand("<cword>")
to get the "word" under the cursor. If the cursor is on a quoted string literal, how would you define a function to get everything between the quotes?
Given this scenario:
foo = "this string has spaces" ^ cursor is here
I want to do
:echo GetStringUnderCursor()
and see
this string has spaces
synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name") == "String"
I just haven't found a way to look up the start and end positions (line and col) for a given syntax region.
Upvotes: 2
Views: 528
Reputation: 31
For example :
vi" -> visual select all inside the quotes
ci" -> change all inside the quotes
yi" -> yank all inside the quotes
If you yank it, you can do :
echo @" -> prints register " (default)
Upvotes: 2