How do I change the text inside parentheses?
Answer
ci(
Explanation
The ci( command deletes everything inside the nearest pair of parentheses and places you in insert mode, ready to type a replacement. It works no matter where your cursor is within the parentheses.
How it works
ctriggers the change operator (delete + enter insert mode)i(is the "inner parentheses" text object, selecting everything between(and)but not the parentheses themselves
Example
Given the text with the cursor anywhere inside the parentheses:
console.log("hello world")
Pressing ci( deletes "hello world" and enters insert mode. Type 42 to get:
console.log(42)
The parentheses are preserved — only the content inside is replaced.
Tips
ci)does exactly the same thing asci(— both refer to the same text object- Use
ca(to change the content and the parentheses themselves - Use
di(to delete inside parentheses without entering insert mode - Use
yi(to yank (copy) the content inside parentheses - This pattern works with other delimiters too:
ci{for braces,ci[for brackets,ci"for double quotes,ci'for single quotes,ci<for angle brackets - Vim finds the nearest enclosing pair, so your cursor does not need to be on the opening parenthesis