4 ms·
>Once vim motions are internalized it’s amazing how efficient it feels to “delete all word” (daw) or “change in paragraph” (cip) without breaking a sweat. The g
by _dain_ 3y ago
>Once vim motions are internalized it’s amazing how efficient it feels to “delete all word” (daw) or “change in paragraph” (cip) without breaking a sweat. The great strength and power of vim motion bindings come from how a few handfuls of general-purpose operations translate across different types of textual motions, from prose to any style of programming and markup languages.
Treesitter makes a lot of these redundant about 70% of the time. You can override "v" so that it just highlights the text comprising the current AST node, e.g. identifier, string literal. And you can keep tapping v to expand the selection to larger enclosing parts of the tree. Press V to shrink it again. This practically subsumes motions like "word", "line", "paragraph", and includes a bunch of other language-specific things like "function call", "for loop", "class body" etc that I'd never remember named motions for. I just put my cursor vaguely near what I want to change, then mindlessly spam v a few times until the selection is what I want, then press c or d or whatever. Be lazy.