|
|
|
|
|
by tasty_freeze
601 days ago
|
|
Say I want to change "foo" to "bar" in a single function in my file. I hit "V" to enter by-line visual mode at the top of the function, go to the end of the function and type ":s/foo/bar/g". If there are other words in the function that contain foo as a substring, then ":s/\<foo\>/bar/g". Please describe your non-roundabout way then. |
|
How would you know that???
So that's the first roundabout eliminated:
- set word selection by default not to have to worry about substrings
But otherwise you're describing a different workflow: while there is no semantic meaning in the "next 5 lines", you actually don't know whether that would be 5 of 7, that's the whole point/benefit of incrementalism, there is in "this function", so block operations are a valid contender and I could also select the function and search&replace within the selection instead of doing word-by-word.
But then the original also works in a more direct way (maybe you actually don't want to replace all "foo" in a function, but skip some of them):
So you would skip your two roundabouts:
- go to the beginning of a function
- go+select to the end of a function
Then proceed with the "direct" way:
- go to your desired word anywhere within the function
- invoke select forward/backward commands until visually reaching the beginning/end of said function (the candidates will all be highlighted)