Blame


1 d739a660 2019-04-06 git # Why vi Rocks
2 18871106 2019-04-06 git
3 18871106 2019-04-06 git 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 18871106 2019-04-06 git These all work with at least [nvi](https://en.wikipedia.org/wiki/Nvi) 1.79 and 2.1.3 (unicode).
5 18871106 2019-04-06 git
6 7d2c94db 2019-04-06 git Helpful documents:<br />
7 7d2c94db 2019-04-06 git - [Roman Zolotarev: Edit text with vi(1)](https://rgz.ee/vi.html)<br />
8 af599e02 2019-04-06 git - [Jeff W: vi help](http://www.jeffw.com/vi/vi_help.txt)<br />
9 ee9f7a40 2019-04-07 git - [Maarten Litmaath: vi reference](http://www.ungerhu.com/jxh/vi.html)<br />
10 ee9f7a40 2019-04-07 git - [alphanrrrd: extremely concise cheatsheet](http://www.alphanrrrd.org/vi.html)<br />
11 af599e02 2019-04-06 git - [ViEmu: Graphical vi cheatsheet](http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html)
12 af599e02 2019-04-06 git
13 6c9b71bc 2019-04-06 git #### Yank / delete an arbitrary number of lines
14 18871106 2019-04-06 git
15 18871106 2019-04-06 git 1) mark the first line: mk
16 18871106 2019-04-06 git 2) move to last line
17 18871106 2019-04-06 git 3a) yank: y'k
18 18871106 2019-04-06 git 3b) delete: d'k
19 18871106 2019-04-06 git 4) move to new line
20 18871106 2019-04-06 git 5) paste with P or p
21 18871106 2019-04-06 git
22 6c9b71bc 2019-04-06 git #### Apply regex to an arbitrary number of lines
23 18871106 2019-04-06 git
24 6c9b71bc 2019-04-06 git 1) mark the first line: mk
25 6c9b71bc 2019-04-06 git 2) mark the last line: ml
26 6c9b71bc 2019-04-06 git :'k,'ls/regex/power/g
27 18871106 2019-04-06 git
28 66a0e66d 2019-04-06 git #### Add # to block of text
29 66a0e66d 2019-04-06 git
30 66a0e66d 2019-04-06 git :'k,'ls/.*/#&/
31 66a0e66d 2019-04-06 git
32 66a0e66d 2019-04-06 git #### Remove trailing whitespace of block of text
33 66a0e66d 2019-04-06 git
34 66a0e66d 2019-04-06 git :'k,'ls/\ *$//
35 66a0e66d 2019-04-06 git
36 6c9b71bc 2019-04-06 git #### Write file as root
37 18871106 2019-04-06 git
38 18871106 2019-04-06 git :w !doas tee %
39 18871106 2019-04-06 git
40 ee594e64 2019-04-06 git #### Diff the file on disk with the file in the buffer
41 18871106 2019-04-06 git
42 18871106 2019-04-06 git :w !diff -u % -
43 18871106 2019-04-06 git
44 18871106 2019-04-06 git #### Make a backup of the file on disk
45 18871106 2019-04-06 git
46 6c9b71bc 2019-04-06 git :!cp % %.bak
47 18871106 2019-04-06 git
48 6c9b71bc 2019-04-06 git #### Sort all lines
49 18871106 2019-04-06 git
50 18871106 2019-04-06 git :%!sort
51 18871106 2019-04-06 git
52 6c9b71bc 2019-04-06 git #### Sort paragraph
53 18871106 2019-04-06 git
54 6c9b71bc 2019-04-06 git !}sort
55 6c9b71bc 2019-04-06 git
56 6c9b71bc 2019-04-06 git #### Uniq all lines
57 6c9b71bc 2019-04-06 git
58 18871106 2019-04-06 git :%!uniq
59 18871106 2019-04-06 git
60 6c9b71bc 2019-04-06 git #### Uniq paragraph
61 18871106 2019-04-06 git
62 6c9b71bc 2019-04-06 git !}uniq
63 6c9b71bc 2019-04-06 git
64 6c9b71bc 2019-04-06 git #### Join all lines
65 6c9b71bc 2019-04-06 git
66 6c9b71bc 2019-04-06 git :%j
67 6c9b71bc 2019-04-06 git
68 6c9b71bc 2019-04-06 git #### Select a column (3rd) from formated text seperated by ':'
69 6c9b71bc 2019-04-06 git
70 6c9b71bc 2019-04-06 git :%!awk -F':' '{print $3}'
71 6c9b71bc 2019-04-06 git
72 6c9b71bc 2019-04-06 git