Read more

IRB's multi-line autocomplete and how to disable it

Arne Hartherz
May 09, 2022Software engineer at makandra GmbH

Recent IRB versions include a multi-line autocomplete which may be helpful to novice users but can be distracting.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Cycling through options works by pressing the Tab key (as usual), and for some methods you also get some kind of documentation, though the quality of results is usually not on par with your IDE of choice.

I have found that it also slows down my IRB in some cases, or that pressing the Backspace key does not always reliably remove characters, which I find more annoying than useful.

You may disable multi-line autocomplete by

  • using the --nomultiline commandline switch (for Rails, use bin/rails console -- --nomultiline), or
  • specifying IRB.conf[:USE_MULTILINE] = false in your ~/.irbrc.

Demo

Note that this disables IRB's multiline cursor navigation. If you like it, you have to pick your poison.

Also note: even when multiline autocomplete is disabled, autocomplete itself (by pressing the Tab key) will still work.
You could use --noautocomplete or IRB.conf[:USE_AUTOCOMPLETE] = false to disable autocompletion in general, but I don't recommend doing that.

Posted by Arne Hartherz to makandra dev (2022-05-09 10:09)