vim note, range patterns

This commit is contained in:
Matthew Ryan Dillon 2021-03-14 14:29:21 -07:00
parent 0b97a4b1d2
commit 2146511ab4
2 changed files with 38 additions and 0 deletions

37
82ded935.md Normal file
View file

@ -0,0 +1,37 @@
---
date: 2021-03-14T14:12
tags:
- vim
---
# 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.
```vim
:/start/,/end/cmd<CR>
```
On a Python file, this might look like:
```python
def main():
foo = do_something()
bar = do_something_else(foo)
return bar
```
```vim
:/def main/,/return/s/foo/baz/g<CR>
```
results in:
```python
def main():
baz = do_something()
bar = do_something_else(baz)
return bar
```

View file

@ -3,3 +3,4 @@
- [[[56653cb1]]]
- [[[fa6a31b4]]]
- [[[b364352b]]]
- [[[82ded935]]]