Moving efficiently
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
0Goes to the start of the linegeEnd of the previous wordbStart of the current wordhPrevious letterlNext lettereEnd of current word (which does not include punctuation)wStart of next wordEEnd of current Word (which includes punctuation)WStart of next Wordt/The character before the next/(or any other key)f/The next/(or any other key)$End of the line
Editing
$ <span style="background:#F0D0D0">cp monfi<span style="color:blue">c</span>hier.txt dir/a</span> S <i>Replace the entire line</i>
$ <span style="background:#F0D0D0">cp monfi<span style="color:blue">c</span></span>hier.txt dir/a c0 d0 <i>Replace or delete to start of line</i>
$ cp <span style="background:#F0D0D0">monfi<span style="color:blue">c</span></span>hier.txt dir/a cb db <i>Replace or delete to the start of the word</i>
$ cp monfi<span style="background:#F0D0D0"><span style="color:blue">c</span></span>hier.txt dir/a s r x <i>Replace or delete the current char</i>
$ cp monfi<span style="background:#F0D0D0"><span style="color:blue">c</span>hier</span>.txt dir/a cw dw <i>Replace or delete to the end of the current word</i>
$ cp monfi<span style="background:#F0D0D0"><span style="color:blue">c</span>hier.txt</span> dir/a cW dW <i>Replace or delete to the end of the current Word</i>
$ cp monfi<span style="background:#F0D0D0"><span style="color:blue">c</span>hier.txt dir</span>/a ct/ dt/ <i>Replace or delete to the next `/` (exclusive)</i>
$ cp monfi<span style="background:#F0D0D0"><span style="color:blue">c</span>hier.txt dir/</span>a cf/ df/ <i>Replace or delete to the next `/` (inclusive)</i>
$ cp monfi<span style="background:#F0D0D0"><span style="color:blue">c</span>hier.txt dir/a</span> C D <i>Replace or delete to the end of the line</i>
$ cp <span style="background:#F0D0D0">monfi<span style="color:blue">c</span>hier</span>.txt dir/a ciw diw <i>Replace or delete the current word</i>
$ cp <span style="background:#F0D0D0">monfi<span style="color:blue">c</span>hier.txt</span> dir/a ciW diW <i>Replace or delete the current Word</i>
-
IInsert at the start of the line -
iInsert at the current position xpSwap the current and next characteraAppend after the current position (the next character)Aappend to the current line
Last update:
November 8, 2020