The first thing I'd recommend doing before anything else is to place the following line in the ~/bashrc file.
$ sudo vi ~/.bashrc
set -o vi
This will apply the vi key bindings to your bash shell and you can use them as you type out commands. So you will have the same two modes in the shell as you do in vim, Insert and Command.
In the shell by default you will be in insert mode so just type as normal.
Hit 'Esc' to go into command mode and use the vi commands in the shell, such as $ to go the end of the line or 0 to go to the beginning of the line.
More below
- b to go back one word
- 2b to go back two words
- dw to delete a word
- dd to delete the entire line
- d$ to delete to the end of the line (from cursor)
- d0 to delete to the beginning of the line (from cursor)
- w to go forward one word
To return back to insert mode type 'i' (as in vi) and you can
then use the terminal as normal.
Vim in vim
Using Vi or Vim, the basic commands you need to actually write files are 'i' to insert text and 'Esc ZZ' to save and exit.
In the command mode, you can move around the file, delete text, etc.