From 6c9b71bcfe73f7253342e064863a4b6ec498cdfd Mon Sep 17 00:00:00 2001 From: mischa Date: Sat, 6 Apr 2019 18:21:54 +0200 Subject: [PATCH] add WIP --- index.md | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/index.md b/index.md index 0678775..6515f6f 100644 --- a/index.md +++ b/index.md @@ -1,9 +1,9 @@ -# Why vi Rocks +# Why vi Rocks (WIP) 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.
These all work with at least [nvi](https://en.wikipedia.org/wiki/Nvi) 1.79 and 2.1.3 (unicode). -#### Yank / delete an arbitrary number of lines. +#### Yank / delete an arbitrary number of lines 1) mark the first line: mk 2) move to last line @@ -12,11 +12,13 @@ These all work with at least [nvi](https://en.wikipedia.org/wiki/Nvi) 1.79 and 2 4) move to new line 5) paste with P or p -#### Join all lines in a file +#### Apply regex to an arbitrary number of lines - :%j + 1) mark the first line: mk + 2) mark the last line: ml + :'k,'ls/regex/power/g -#### When you need root permissions to write the file +#### Write file as root :w !doas tee % @@ -26,14 +28,30 @@ These all work with at least [nvi](https://en.wikipedia.org/wiki/Nvi) 1.79 and 2 #### Make a backup of the file on disk - :! cp % %.bak + :!cp % %.bak -#### Sort lines +#### Sort all lines :%!sort -#### Dedup lines +#### Sort paragraph + + !}sort + +#### Uniq all lines :%!uniq +#### Uniq paragraph + + !}uniq + +#### Join all lines + + :%j + +#### Select a column (3rd) from formated text seperated by ':' + + :%!awk -F':' '{print $3}' +