E-learning module "Linux Basics"
Short Introduction to vim
- Command mode → In this mode the editor can be controlled and configured.
- Insert mode → Text can be added, deleted or replaced.
After the launch of vim, the command mode is the default setting.
The ESC-key is used to switch from insert to command mode.
To switch from command to insert mode, use a command.
A selection of vim commands – cursor control:
0 → Begin of the line.$ → End of the line.^ → First non-space character of the line.G → Begin of the last line.[n]G → Begin of line n.w → Next word.[n]w → n words.b → Back for one word.[n]b → Back for n words.h (or matching arrow key) → A character to the left. l (or matching arrow key) → A character to the right.k (or matching arrow key) → One line up.j (or matching arrow key) → One line down.
Ctrl + F → Page down.
Ctrl + B → Page up.
A selection of vim commands – edit:
dw → Delete current word.D or d$ → Delete from the current character to the line end.d0 or d^ → Delete from beginning of the line to the current character.dd → Delete current line.[n]dd → Delete n lines (including the current line).[n]yy → Copy n lines to the buffer.p → Place the buffer.[n] → Repeat the last command n times.:! command → Execute a shell command.:!! → Repeat last shell command.
A selection of vim commands – file:
:w → Write file.:w filename → Save with new file name.:q → Quit vim.:x or :wq → Save and quit (=exit) vim.:q! → Quit vim and discard changes.:r → Insert file.
The content of this e-learning module is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license (CC BY-NC-SA 3.0 DE). |
