14 ms·
> now find JUNK and replace 'a1' with 'A1' in the 15 lines that follow The real scenario is usually to replace, for example, in a function block. How do you do
by lostmsu 6y ago
> now find JUNK and replace 'a1' with 'A1' in the 15 lines that follow
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.
- jcranmer 6y agoHighlighting 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.
- joatmon-snoo 6y agoMine is v% :)
- tvb12 6y agoIf 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/textobj-indent.txt 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.
- alwillis 6y agoYou 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.