When copy/pasting from irb to an .rb
file the start of each line should be removed.
A short example, say you copy this from irb:
irb(main):049:1* def thing(x, y)
irb(main):050:1* out = x * y
irb(main):051:1* puts out
irb(main):052:0> end
=> :thing
irb(main):053:0> thing(2, 3)
6
=> nil
it would be handy to paste only this:
def thing(x, y)
out = x * y
puts out
end
=> :thing
thing(2, 3)
6
=> nil
Is there any special copy/paste command to achieve this, either already built into irb, available through some sort of extension, or even operating system shortcut (running macOS)?
A regular expression could be used to remove the prompts, but it's not ideal since it assumes the paste will be into a text editor with find and replace with regex.
Although completely unrelated to rails, Google Docs, has a convention of cmd + shift + paste to 'paste without formatting'. I'm after something similar for irb like 'copy without prompt'.
Note: I'm using the macOS terminal (zsh)
You can hold the ⌥ Option key and drag for a rectangular selection:
You can also customize IRB's prompt. Here's an example of the built-in --noprompt
option which provides a blank prompt: