mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Edit Previous Parts Of The Pry Buffer History as a ruby til
This commit is contained in:
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
|
||||
warrant a full blog post. These are mostly things I learn by pairing with
|
||||
smart people at [Hashrocket](http://hashrocket.com/).
|
||||
|
||||
_423 TILs and counting..._
|
||||
_424 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -303,6 +303,7 @@ _423 TILs and counting..._
|
||||
- [Destructuring Arrays In Blocks](ruby/destructuring-arrays-in-blocks.md)
|
||||
- [Disassemble Some Codes](ruby/disassemble-some-codes.md)
|
||||
- [Double Splat To Merge Hashes](ruby/double-splat-to-merge-hashes.md)
|
||||
- [Edit Previous Parts Of The Pry Buffer History](ruby/edit-previous-parts-of-the-pry-buffer-history.md)
|
||||
- [Editing Code In Pry](ruby/editing-code-in-pry.md)
|
||||
- [Evaluating One-Off Commands](ruby/evaluating-one-off-commands.md)
|
||||
- [FactoryGirl Sequences](ruby/factory-girl-sequences.md)
|
||||
|
||||
29
ruby/edit-previous-parts-of-the-pry-buffer-history.md
Normal file
29
ruby/edit-previous-parts-of-the-pry-buffer-history.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Edit Previous Parts Of The Pry Buffer History
|
||||
|
||||
Each line of Ruby you enter into a Pry session is recorded with a number in
|
||||
the buffer history. Pry keeps this buffer history so that you can recall
|
||||
parts of it for editing and subsequent execution.
|
||||
|
||||
If you use the `edit` command by itself, Pry will open the previous Ruby
|
||||
statement in your default editor. But what if you want to edit a statement
|
||||
from a while back? Or even a series of statements?
|
||||
|
||||
Use the `--in` flag with `edit` either specifying a single record in the
|
||||
buffer history or a range of records.
|
||||
|
||||
```ruby
|
||||
$ pry
|
||||
[1] pry(main)> puts "Hello"
|
||||
Hello
|
||||
=> nil
|
||||
[2] pry(main)> puts "World"
|
||||
World
|
||||
=> nil
|
||||
[3] pry(main)> puts "People"
|
||||
People
|
||||
=> nil
|
||||
[4] pry(main)> edit --in 1..2
|
||||
Hello
|
||||
World
|
||||
=> nil
|
||||
```
|
||||
Reference in New Issue
Block a user