Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you move the cursor to the end of a string in Vim?

Tags:

vim

vi

Let's say I'm editing this line of JavaScript in Vim:

var opener = 'As Gregor Samsa awoke one morning from uneasy dreams he found himself transformed in his bed into a gigantic insect';

If my cursor is on the G in Gregor, how do I move it to the t in insect?

I'm not talking about moving to the end of the line. I'm talking about moving to the end of the JavaScript string encapsulated in the single quotation marks. (I know I can do it with /'h, but I'm wondering if there's a more generic command—maybe something like %.)

like image 854
Joe Mornin Avatar asked Dec 05 '25 05:12

Joe Mornin


1 Answers

There's vi'<Esc>, which goes into visual mode with the selection comprising the interior of the current string, and the cursor at the end of the selection — then leaves visual mode.

I'm not sure if there's a better way.

like image 110
hobbs Avatar answered Dec 08 '25 11:12

hobbs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!