# Using Vim effectively
Vim is a very powerful text editor that makes manipulating text much easier and faster once it's commands are embedded into memory. The easiest way of understanding the core aspects of using vim would be to use it's built in tutorial. Run
:tutor
1
and complete it. Re-run it as many times as necessary.
# Normal Commands
i
- insert modeu
- undo lastU
- Undo linedd
- delete(and copy) linep
- pastegg
- move cursor to first line42G
- move to start of line 42dG
- delete all linesg=GG
- indent all linesgg"+yG
- copy all lines (+
: to system clipboard):%y+
- copy all lines (%
: affect all lines`)
# Commands (invoked with :
)
:q
- quit:q!
- quit, discarding changes:w
- save:wq
- save and quit:x
- save and quit:r !xsel -b
- copy clipboard contents to file
To save a file (:w) that was opened as Read-only:
:w !sudo tee %
1
# Registers
:reg
- view registers".
- last entered text"%
- current file path":
- most recently executed command