Blob


1 # Why vi Rocks
3 A collection of commands, command sequences in [vi(1)](https://man.openbsd.org/vi.1)/[ex(1)](https://man.openbsd.org/ex.1) or with 3rd party unitilities.<br />
4 These all work with at least [nvi](https://en.wikipedia.org/wiki/Nvi) 1.79 and 2.1.3 (unicode).
6 #### Yank / delete an arbitrary number of lines.
8 1) mark the first line: mk
9 2) move to last line
10 3a) yank: y'k
11 3b) delete: d'k
12 4) move to new line
13 5) paste with P or p
15 #### Join all lines in a file
17 :%j
19 #### When you need root permissions to write the file
21 :w !doas tee %
23 #### Diff the file on disk with the file in cache
25 :w !diff -u % -
27 #### Make a backup of the file on disk
29 :! cp % %.bak
31 #### Sort lines
33 :%!sort
35 #### Dedup lines
37 :%!uniq