keyboard shortcuts:
Moving around
Ctrl-a Move the cursor ⇤ to the start of the line
Ctrl-e Move the cursor ⇥ to the end of the line
Alt-b Move the cursor one word ⇦ to the left
Alt-f Move the cursor one word ⇨ to the right
Ctrl-x-x Move the cursor ⇤⇥ to the start, and to the end again
Cut, copy and paste
Ctrl-u Delete everything ⇤ from the cursor back to the line start
Ctrl-k Delete everything ⇥ from the cursor to the end of the line
Alt-d Delete word ⇨ untill before the next word boundary
Ctrl-w Delete word ⇦ untill after the previous word boundary
Ctrl-y Yank/Paste prev. killed text at the cursor position
Undo
Ctrl-_
Ctrl+- Undo the last editing command; you can undo all the way back to an empty
line
History
Ctrl-p Move in history one line ⇧ before this line
Ctrl-n Move in history one line ⇩ after this line
Alt-> Move in history all the lines ⇩ to the line currently being entered
Ctrl-r Incrementally search the line history ⇧ backwardly
Ctrl-s Incrementally search the line history ⇩ forwardly
Ctrl-J End an incremental search
Ctrl-G Abort an incremental search and restore the original line
==============================================================================
Integrate readline into a ruby program:
require 'readline'
while line = Readline.readline('> ', history = true)
break if line =~ /^(quit|exit)$/
puts "You typed: #{line.inspect}"
end
puts "Bye!"
# completion
require 'abbrev'
Completors = %w[hello world of nifty_completion]
Readline.completion_proc = lambda{|tok| Completors.abbrev[tok] }