Skip to content

Commit 22c1e1a

Browse files
committed
Add Edit Previous Parts Of The Pry Buffer History as a ruby til
1 parent 6ce02bd commit 22c1e1a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77
warrant a full blog post. These are mostly things I learn by pairing with
88
smart people at [Hashrocket](http://hashrocket.com/).
99

10-
_423 TILs and counting..._
10+
_424 TILs and counting..._
1111

1212
---
1313

@@ -303,6 +303,7 @@ _423 TILs and counting..._
303303
- [Destructuring Arrays In Blocks](ruby/destructuring-arrays-in-blocks.md)
304304
- [Disassemble Some Codes](ruby/disassemble-some-codes.md)
305305
- [Double Splat To Merge Hashes](ruby/double-splat-to-merge-hashes.md)
306+
- [Edit Previous Parts Of The Pry Buffer History](ruby/edit-previous-parts-of-the-pry-buffer-history.md)
306307
- [Editing Code In Pry](ruby/editing-code-in-pry.md)
307308
- [Evaluating One-Off Commands](ruby/evaluating-one-off-commands.md)
308309
- [FactoryGirl Sequences](ruby/factory-girl-sequences.md)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Edit Previous Parts Of The Pry Buffer History
2+
3+
Each line of Ruby you enter into a Pry session is recorded with a number in
4+
the buffer history. Pry keeps this buffer history so that you can recall
5+
parts of it for editing and subsequent execution.
6+
7+
If you use the `edit` command by itself, Pry will open the previous Ruby
8+
statement in your default editor. But what if you want to edit a statement
9+
from a while back? Or even a series of statements?
10+
11+
Use the `--in` flag with `edit` either specifying a single record in the
12+
buffer history or a range of records.
13+
14+
```ruby
15+
$ pry
16+
[1] pry(main)> puts "Hello"
17+
Hello
18+
=> nil
19+
[2] pry(main)> puts "World"
20+
World
21+
=> nil
22+
[3] pry(main)> puts "People"
23+
People
24+
=> nil
25+
[4] pry(main)> edit --in 1..2
26+
Hello
27+
World
28+
=> nil
29+
```

0 commit comments

Comments
 (0)