3 ms·
I consider myself at least an intermediate user of Vim, and I'm glad that you mentioned the "f" motion (along with its cousins "t" and ";"). I don't think these
by blymphony 11y ago
I consider myself at least an intermediate user of Vim, and I'm glad that you mentioned the "f" motion (along with its cousins "t" and ";"). I don't think these keys get enough exposure among beginner Vim users (they aren't mentioned in vimtutor), but they allow you to quickly and efficiently move across files and do things like "ct(" (change text up to first left parentheses), which is super useful for changing function names.
Shameless plug: I wrote a plugin (https://github.com/unblevable/quick-scope https://github.com/unblevable/quick-scope) that facilitates the use of "f" and family that even beginners can take advantage of.
- 0942v8653 11y agoThe commands you mentioned along with "ci'", "ci[", and "ciW" to replace all text between delimiters have been some of my favorite to use. It really annoys me when my terminal's vi-mode doesn't support "ci" (I think it's vim-only).
- nitrogen 11y agoThe "ci" and "ca" commands are part of a Vim-only feature called Text Objects (type :help objects in Vim's command mode, or search the web). I like using yap and dap to copy/move paragraphs around when I'm editing markdown text.
- orodley 11y ago% is really useful for dealing with functions too. For example, deleting "foo(a + bar(x, y) + c)" by placing the cursor on the "f" and executing "d%".
- mdup 11y agoBy the way, in your specific example, "ct(" is not necessarily the most efficient, because most of the time a function name will be a nice alphanumeric string; hence you can use "ciw" which will work anywhere in the string, not only at the beginning.