646 B
646 B
date | tags | |
---|---|---|
2021-03-14T14:12 |
|
command mode ranges based on patterns
In command mode you can specify a range of lines to operate on, based on patterns, rather than absolute (or relative line numbers). This can be a great way to isolate changes without looking up the individual line numbers.
:/start/,/end/cmd<CR>
On a Python file, this might look like:
def main():
foo = do_something()
bar = do_something_else(foo)
return bar
:/def main/,/return/s/foo/baz/g<CR>
results in:
def main():
baz = do_something()
bar = do_something_else(baz)
return bar