There's not a command that follows the ci...
structure to do that. You can
add a remap to do it (see below), or use core vim commands f
and t
(and
their counterparts F
and T
) motions to get the cursor to where you want,
and then switch to insert mode (with i
or a
) to effect the change (see even
further below).
Adding a remap to do it
Here's a mapping to do it:
nnoremap <LEADER>ci" ci"<C-r>"
The way it works: The ctrl + r
+ "
pastes from the unnamed register once in
insert mode - and since the unnamed register will contain whatever was between
the double quotes it just pastes it back in and leaves you in insert mode to
append your string:
Showing how the map works, step by step:
if (name == "Frank") {
ci"
(this leaves you in insert mode)
if (name == "") {
ctrl+r
+ "
(this pastes the content back, and leaves you in insert mode)
if (name == "Frank") {
Typing your addition && lastName == "Castle"
:
if (name == "Frank && lastName == "Castle") {
Using core vim (i.e. without a remap)
Relevant stuff from the help:
f{char} To [count]'th occurrence of {char} to the right. The
cursor is placed on {char}...
F{char} To the [count]'th occurrence of {char} to the left.
The cursor is placed on {char}...
t{char} Till before [count]'th occurrence of {char} to the
right. The cursor is placed on the character left of
{char}...
T{char} Till after [count]'th occurrence of {char} to the
left. The cursor is placed on the character right of
{char}...
; Repeat latest f, t, F or T [count] times.
, Repeat latest f, t, F or T in opposite direction
[count] times.
In the following, the ^
shows where the cursor is.
First case
if (name == "Frank") {
^
Pressing f)
:
if (name == "Frank") {
^
Typing i && lastName == "Castle"
:
if (name == "Frank" && lastName == "Castle") {
Second case
if (name == "Frank") {
^
Pressing t)
or f";
or 2f"
:
if (name == "Frank") {
^
Typing i Castle
:
if (name == "Frank Castle") {
^
Going backwards with F
if (name == "Frank") {
^
Pressing F"
:
if (name == "Frank") {
^
Going backwards with T
if (name == "Frank") {
^
Pressing T";
or 2T"
:
if (name == "Frank") {
^