1 d739a660 2019-04-06 git # Why vi Rocks
3 7b150fff 2019-04-07 git **[vi](https://en.wikipedia.org/wiki/Vi)** is the _de facto_ standard
4 7b150fff 2019-04-07 git Unix editor, you find it in every *NIX derived OS.
6 7b150fff 2019-04-07 git Here you will find a collection of commands, command sequences in
7 7b150fff 2019-04-07 git [vi(1)](https://man.openbsd.org/vi.1)/[ex(1)](https://man.openbsd.org/ex.1)
8 7b150fff 2019-04-07 git or with 3rd party unitilities which make
9 7b150fff 2019-04-07 git **[vi](https://en.wikipedia.org/wiki/Vi)** rock. These all work
10 7b150fff 2019-04-07 git with at least [nvi](https://en.wikipedia.org/wiki/Nvi) 1.79 and
11 7b150fff 2019-04-07 git 2.1.3 (unicode).
13 7d2c94db 2019-04-06 git Helpful documents:<br />
14 7d2c94db 2019-04-06 git - [Roman Zolotarev: Edit text with vi(1)](https://rgz.ee/vi.html)<br />
15 af599e02 2019-04-06 git - [Jeff W: vi help](http://www.jeffw.com/vi/vi_help.txt)<br />
16 ee9f7a40 2019-04-07 git - [Maarten Litmaath: vi reference](http://www.ungerhu.com/jxh/vi.html)<br />
17 ee9f7a40 2019-04-07 git - [alphanrrrd: extremely concise cheatsheet](http://www.alphanrrrd.org/vi.html)<br />
18 af599e02 2019-04-06 git - [ViEmu: Graphical vi cheatsheet](http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html)
20 6c9b71bc 2019-04-06 git #### Yank / delete an arbitrary number of lines
22 18871106 2019-04-06 git 1) mark the first line: mk
23 18871106 2019-04-06 git 2) move to last line
24 18871106 2019-04-06 git 3a) yank: y'k
25 18871106 2019-04-06 git 3b) delete: d'k
26 7b150fff 2019-04-07 git 4) move to destination line
27 7b150fff 2019-04-07 git 5) put with P or p
29 6c9b71bc 2019-04-06 git #### Apply regex to an arbitrary number of lines
31 6c9b71bc 2019-04-06 git 1) mark the first line: mk
32 6c9b71bc 2019-04-06 git 2) mark the last line: ml
33 6c9b71bc 2019-04-06 git :'k,'ls/regex/power/g
35 66a0e66d 2019-04-06 git #### Add # to block of text
37 66a0e66d 2019-04-06 git :'k,'ls/.*/#&/
39 66a0e66d 2019-04-06 git #### Remove trailing whitespace of block of text
41 66a0e66d 2019-04-06 git :'k,'ls/\ *$//
43 6c9b71bc 2019-04-06 git #### Write file as root
45 18871106 2019-04-06 git :w !doas tee %
47 ee594e64 2019-04-06 git #### Diff the file on disk with the file in the buffer
49 18871106 2019-04-06 git :w !diff -u % -
51 18871106 2019-04-06 git #### Make a backup of the file on disk
55 6c9b71bc 2019-04-06 git #### Sort all lines
59 6c9b71bc 2019-04-06 git #### Sort paragraph
63 f931c46b 2019-04-07 git <sub><sup>} won't be shown in the command.</sup></sub>
65 9ad69938 2019-04-07 git #### Sort from current line to EOF
69 9ad69938 2019-04-07 git <sub><sup>G won't be shown in the command.</sup></sub>
71 6c9b71bc 2019-04-06 git #### Uniq all lines
75 6c9b71bc 2019-04-06 git #### Uniq paragraph
79 f931c46b 2019-04-07 git <sub><sup>} won't be shown in the command.</sup></sub>
81 9ad69938 2019-04-07 git #### Uniq from current line to EOF
85 9ad69938 2019-04-07 git <sub><sup>G won't be shown in the command.</sup></sub>
87 6c9b71bc 2019-04-06 git #### Join all lines
91 6c9b71bc 2019-04-06 git #### Select a column (3rd) from formated text seperated by ':'
93 6c9b71bc 2019-04-06 git :%!awk -F':' '{print $3}'