I work with PHP and Javascript a lot and I find that I am often adding an open parenthesis ( in the middle of a line somewhere (calling a function or something) and then I need to move to the end of the line to close it…
example (before edits):
array(
'key' => 'value sometimes long and with \',() in string',
example (after initial edit – exit insert mode on the close paren )):
array(
'key' => Class::method('value sometimes long and with \',() in string',
^ cursor here after exiting insert mode
desired cursor position in insert mode:
array(
'key' => Class::method('value sometimes long and with \',() in string',
cursor before comma in insert mode ^
obviously, I could do $hi to move to the end of the line, move back one character and enter insert mode… or I could do A< to enter insert mode at the EOL and left arrow one place.
I was wondering if anyone knew of any easier/better way to do this?
Better yet, I am imagining a simple function to “know” if the last character is a comma or semicolon, and move to the last character and only move left if the last character is a comma or semicolon.
pseudo code idea: $("am I on a comma or semicolon" ? h : )i
I would do
iClass::method<Esc>lva'S)with the excellent Surround.vim plugin by Tim Pope.