Skip to content

Instantly share code, notes, and snippets.

@bookercodes
Created February 27, 2016 20:00
Show Gist options
  • Save bookercodes/69dd3a41c26570b36280 to your computer and use it in GitHub Desktop.
Save bookercodes/69dd3a41c26570b36280 to your computer and use it in GitHub Desktop.

Motions

As you probably already know, you can use the ci( motion to change the text within 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 😄!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment