As you probably already know, you can use the ci(
motion to c
hange the text withi
n parentheses ((
).
With your cursor on or in the parentheses:
(^
represents the current cursor position.)
func foo(argument) { }
........^
... When in normal mode, writing ci(
will delete the text between the nearest parentheses and put you in insert mode:
func foo() { }
........^
... You can then make your edit and press Esc
to return to normal mode.
What you might not know is that your cursor doesn't strictly have to be on or within the parentheses. It can actually be anywhere before the parentheses whose text you want to edit. That includes the beginning of the line:
func foo(argument) { }
^
... When in normal mode, with your cursor at the beginning of the line, write ci(
to make the same edit:
func foo() { }
........^
I cannot tell you how many times I've manually moved the cursor right (using
l
; w
; or, if I was feeling particularly efficient, f(
) before writing ci(
.
This tip doesn't just apply to the ci(
motion. It applies to all the motions
I've tried, including Control-a
(which increments a number) and Control-x
(which decrements a number). Try it out and tell me what you think 😄!