# Moving efficiently on the command line

This chart shows where different vi movement and editing keystrokes will take you on the command line, inspired by Clément Chastagnol's "Moving efficiently on the command line", which showed the same thing for emacs key bindings. If you want to experiment with it in bash, type set -o vi to enable vi key bindings. To enable them in your shell and other readline tools:

echo 'set editing-mode vi' > ~/.inputrc
echo 'bind -v' > ~/.editrc
echo 'export EDITOR="vim"' >> ~/.bashrc


### Movement

• 0 Goes to the start of the line
• ge End of the previous word
• b Start of the current word
• h Previous letter
• l Next letter
• e End of current word (which does not include punctuation)
• w Start of next word
• E End of current Word (which includes punctuation)
• W Start of next Word
• t/ The character before the next / (or any other key)
• f/ The next / (or any other key)
• $End of the line ### Editing $ cp monfichier.txt dir/a    S         Replace the entire line
$cp monfichier.txt dir/a c0 d0 Replace or delete to start of line$ cp monfichier.txt dir/a    cb  db    Replace or delete to the start of the word
$cp monfichier.txt dir/a s r x Replace or delete the current char$ cp monfichier.txt dir/a    cw  dw    Replace or delete to the end of the current word
$cp monfichier.txt dir/a cW dW Replace or delete to the end of the current Word$ cp monfichier.txt dir/a    ct/ dt/   Replace or delete to the next / (exclusive)
$cp monfichier.txt dir/a cf/ df/ Replace or delete to the next / (inclusive)$ cp monfichier.txt dir/a    C   D     Replace or delete to the end of the line
$cp monfichier.txt dir/a ciw diw Replace or delete the current word$ cp monfichier.txt dir/a    ciW diW   Replace or delete the current Word

• I Insert at the start of the line
• i Insert at the current position
• xp Swap the current and next character
• a Append after the current position (the next character)
• A append to the current line