---
# System prepended metadata

title: VIM for the heretics

---

VIM for the heretics
===

Cheatsheet commands for heretics, who used to use Visual studio code or the like.

## Move

"Avoid the mouse", is the Vim philosophy. 

For that, use `h j k l` to go left, down, up, right respectively.

## Escape

Anytime, in case of doubt, `escape` yourself, again and again. Or [breakout](https://www.youtube.com/watch?v=-P67b07z7Qw).

## Edit & remove

`i` for edit mode
`a` idem than `i` but move the cursor to the next character
`o` idem than `i` but insert a new line
`x` to remove the current char

## Save and quit & Unsave and quit 

`:q` to quit (won't work if you've made modifications. See below)
`:wq` to save and quit
`:q!` to quit and not save your modifications

## Copy & paste

The syntax in Vim is:
- y for yank (aka copy)
- p for put (aka paste)
- d for delete (aka cut)
- c for change

### for a line

`dd` for deleting a line and put it in the buffer (aka cut or delete)
`yy` for copying the line in the buffer (aka copy or yank)
`p` or `P` for pasting the buffer on the following line or the current one
`cw` for changing word, i.e. delete a word and pass to edit mode

### for characters

`v` to select char
`V` to select the entire line
`Ctl-v` to select rectangular block
`d` to delete (aka cut)    
`y` to copy (aka copy or yank)

### Copy in clipboard

`:"*yiw"` to copy the inner word
`":*yy"` to copy the current line

## Undo & redo

`u` for undoing
`Ctl-r` for redoing
`U` undoing all change in one line. Avoid this weird command, please, and undo it.

## Quick move in lines

`^` and `$` to go to start and end of a line (this is regex-like)
`w` and `b` to go one word at a times and backward (`W` is an alternative to `w`)



## See line number

`:set number`

To toggle, use `:set number!` or `:set nu!:`

Relative number is useful to see the current line as the zero line. Copy can be much easier this way.

`:set relativenumber` or `:set rnu`