When you press Ctrl+L in bash default mode the screen is cleared. But when I run set -o vi and press Ctrl+L the keystroke is printed (^L). Is there any way to keep this behavior?

2 Answers 2


Ctrl+L is also bound in vi command mode but not in insert mode. There's no default binding for clear-screen in insert mode. Readline bindings should be specified in ~/.inputrc, like so:

set editing-mode vi
$if mode=vi

set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen

set keymap vi-insert
# these are for vi-insert mode
Control-l: clear-screen 

This will bind Ctrl+L to clear the screen in both normal and insert mode. Naturally, if you prefer to only use it in one mode, just remove the relevant option.

If you prefer to set this just for bash use the following equivalents in ~/.bashrc:

set -o vi
bind -m vi-command 'Control-l: clear-screen'
bind -m vi-insert 'Control-l: clear-screen'

There is an extensive list of readline commands that you can use to customize your bash shell with.

  • 3
    out of curiosity, why bother with vi-command if it's already mapped? just for the sake of completeness, or is there a technical reason? Oct 10, 2017 at 13:43
  • 3
    @KenBellows for clarity, as per the comments (and I needed an example in the vi-command block for purely aesthetic reasons).
    – jasonwryan
    Oct 10, 2017 at 15:17
  • @jasonwryan "set editing-mode vi" -- instead of this if the vi option is set in bash (set -o vi), then what would replace this part: $if mode=vi ?
    – Lavya
    Apr 15, 2020 at 23:44

Put this line in your bashrc:

bind -m vi-insert "\C-l":clear-screen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.