If the language uses curly braces to define blocks, it's easier: ciB. Parentheses are easy as well: cib.
Otherwise, I'm not sure there's a good solution currently. You can substitute by indentation with a plugin (https://github.com/kana/vim-textobj-indent/blob/master/doc/t...). For Lua, I usually do c/end<enter>.
I believe this is an area where treesitter can help, so I'm looking forward to Neovim's integration.
Highlighting the initial { of a function and then typing 'va}' ('v' for entering visual mode, and 'a}' moves to the matching close brace. Similar commands work the [], (), and <> pairs) selects the entire function body. From there, a regular s command will operate on the entire selected text.
Re:How Did Vim Become So Popular?
by joatmon-snoo on Tuesday June 30, 2020 @10:24PM
(#23697069)
Mine is v% :)
You know these aren’t new issues, right? Vim has been around since 1991 and back to 1976 from Bill Joy’s editor.
Of course Vim can replace a function block easily and has been able to do so for decades.
The real scenario is usually to replace, for example, in a function block. How do you do that? Counting function lines seems like a non-starter.