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?

up vote 55 down vote accepted

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.

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

  • 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? – Ken Bellows Oct 10 '17 at 13:43
  • 1
    @KenBellows for clarity, as per the comments (and I needed an example in the vi-command block for purely aesthetic reasons). – jasonwryan Oct 10 '17 at 15:17

Put this line in your bashrc:

bind -m vi-insert "\C-l":clear-screen
  • Much cleaner answer! Thanks! – math2001 Sep 16 '17 at 5:56

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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