Blame


1 d739a660 2019-04-06 git # Why vi Rocks
2 18871106 2019-04-06 git
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.
5 18871106 2019-04-06 git
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).
12 7b150fff 2019-04-07 git
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)
19 af599e02 2019-04-06 git
20 6c9b71bc 2019-04-06 git #### Yank / delete an arbitrary number of lines
21 18871106 2019-04-06 git
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
28 18871106 2019-04-06 git
29 6c9b71bc 2019-04-06 git #### Apply regex to an arbitrary number of lines
30 18871106 2019-04-06 git
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
34 18871106 2019-04-06 git
35 66a0e66d 2019-04-06 git #### Add # to block of text
36 66a0e66d 2019-04-06 git
37 66a0e66d 2019-04-06 git :'k,'ls/.*/#&/
38 66a0e66d 2019-04-06 git
39 66a0e66d 2019-04-06 git #### Remove trailing whitespace of block of text
40 66a0e66d 2019-04-06 git
41 66a0e66d 2019-04-06 git :'k,'ls/\ *$//
42 66a0e66d 2019-04-06 git
43 6c9b71bc 2019-04-06 git #### Write file as root
44 18871106 2019-04-06 git
45 18871106 2019-04-06 git :w !doas tee %
46 18871106 2019-04-06 git
47 ee594e64 2019-04-06 git #### Diff the file on disk with the file in the buffer
48 18871106 2019-04-06 git
49 18871106 2019-04-06 git :w !diff -u % -
50 18871106 2019-04-06 git
51 18871106 2019-04-06 git #### Make a backup of the file on disk
52 18871106 2019-04-06 git
53 6c9b71bc 2019-04-06 git :!cp % %.bak
54 18871106 2019-04-06 git
55 6c9b71bc 2019-04-06 git #### Sort all lines
56 18871106 2019-04-06 git
57 18871106 2019-04-06 git :%!sort
58 18871106 2019-04-06 git
59 6c9b71bc 2019-04-06 git #### Sort paragraph
60 18871106 2019-04-06 git
61 6c9b71bc 2019-04-06 git !}sort
62 6c9b71bc 2019-04-06 git
63 9ad69938 2019-04-07 git #### Sort from current line to EOF
64 9ad69938 2019-04-07 git
65 9ad69938 2019-04-07 git !Gsort
66 9ad69938 2019-04-07 git
67 9ad69938 2019-04-07 git <sub><sup>G won't be shown in the command.</sup></sub>
68 9ad69938 2019-04-07 git
69 6c9b71bc 2019-04-06 git #### Uniq all lines
70 6c9b71bc 2019-04-06 git
71 18871106 2019-04-06 git :%!uniq
72 18871106 2019-04-06 git
73 6c9b71bc 2019-04-06 git #### Uniq paragraph
74 18871106 2019-04-06 git
75 6c9b71bc 2019-04-06 git !}uniq
76 6c9b71bc 2019-04-06 git
77 9ad69938 2019-04-07 git #### Uniq from current line to EOF
78 9ad69938 2019-04-07 git
79 9ad69938 2019-04-07 git !Guniq
80 9ad69938 2019-04-07 git
81 9ad69938 2019-04-07 git <sub><sup>G won't be shown in the command.</sup></sub>
82 9ad69938 2019-04-07 git
83 6c9b71bc 2019-04-06 git #### Join all lines
84 6c9b71bc 2019-04-06 git
85 6c9b71bc 2019-04-06 git :%j
86 6c9b71bc 2019-04-06 git
87 6c9b71bc 2019-04-06 git #### Select a column (3rd) from formated text seperated by ':'
88 6c9b71bc 2019-04-06 git
89 6c9b71bc 2019-04-06 git :%!awk -F':' '{print $3}'
90 6c9b71bc 2019-04-06 git
91 6c9b71bc 2019-04-06 git