• Home
  • Blogger
  • Github
  • Travel
  • The Tank Project
skip to main | skip to sidebar

Steven Occhipinti

A braindump.

Vi mode for Bash

So it turns out bash has a vi mode!
(Can't believe I didn't know about this earlier)

To enable vi mode, just type this into your shell:
$> set -o vi

That will enable it for this shell so you can try it out, and if you like it, add that line to your ~/.bashrc file for future.

One really useful vi-mode command is pressing 'v' from command mode. This will put your current command line into vim to modify.

To get more help on the commands available in vi-mode, take a look at the bottom of this man page:
$> man 3 readline

To get more information on the various options available for bash, take a look at:
$> help set

I'm going to give it ago in the coming weeks to see if its actually useful or not.

So far, I've found one small annoyance, I use ctrl+l to clear the terminal, but with the vi key bindings enabled, this only works from command mode (you have to hit ESC first).
To fix this, I added this to my ~/.bashrc file:
bind -m vi-insert 'Control-l: clear-screen'

These commands could also be added to /etc/inputrc, but I'm happy to leave these 2 lines together in my ~/.bashrc so its easier to remember.
Posted by Steve at 09:22
Labels: bash , linux , vim Email This BlogThis! Share to X Share to Facebook

1 comments:

Unknown said...

your binding for c-l is from heaven. Thanks!

31 August 2012 at 16:31

Post a Comment

Newer Post Older Post Home

Blog Archive

  • ►  2013 (4)
    • ►  June (1)
    • ►  May (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2012 (17)
    • ►  December (1)
    • ►  October (1)
    • ►  September (2)
    • ►  August (2)
    • ►  July (1)
    • ►  May (2)
    • ►  April (2)
    • ►  March (3)
    • ►  February (3)
  • ▼  2011 (33)
    • ►  December (1)
    • ►  November (3)
    • ►  October (3)
    • ►  September (4)
    • ►  August (3)
    • ►  July (4)
    • ▼  June (6)
      • Vi mode for Bash
      • PhpRemoteAdmin
      • Bash auto-complete
      • Can't open file for writing
      • Flashy Prezis @ DDD
      • Flashy Prezis @ DDD
    • ►  May (6)
    • ►  April (3)

Labels

android (5) apache (1) arch linux (1) arduino (1) bash (11) calendar (1) compiz (1) design (1) diff (1) email (1) gimp (1) git (3) github (2) gnome3 (1) Google (2) hacking (1) hardware (4) howto (1) htpc (1) java (1) lamp (1) linux (28) Mac (2) minecraft (2) mysql (1) netduino (1) nfs (1) parallel port (1) patch (1) photography (4) php (1) pidgin (2) printer (1) programming (6) python (1) rails (1) regex (5) review (3) ruby (3) Samsung Galaxy S3 (2) Samsung Series 9 (1) security (1) sed (3) ssh (1) sudo (1) tank (2) Toshiba Portege (1) troubleshooting (1) ubuntu (16) ui (2) unity (2) vim (5) webcam (1) websites (3) xbmc (1) xclip (1) xul (1)

Total Pageviews

Sparkline
 
Copyright (c) 2010 Steven Occhipinti. Designed by Conveyancing
High Deductible Health Insurance, Purchase Beats