Commit Diff


commit - f931c46b7be44818f5a4e9830696ae8eda1f8e0f
commit + 9541feb7d631aaf167e0150595699f792448e420
blob - 186b78af17cb9a86beeaad7f3ff19d34c182acee
blob + 1563ea74a5378d3ff9188228a34854c36a8cabe5
--- index.md
+++ index.md
@@ -84,12 +84,56 @@ Helpful documents:<br />
 
 <sub><sup>G won't be shown in the command.</sup></sub>
 
+#### Underline all lines starting with CHAPTER
+
+	:g/^CHAPTER /t.|s/./=/g
+
+#### Search for "pattern", print the containing function (start with def) and line number
+
+	:g/pattern/?^ *def ?#
+
+#### Add # to paragraph containing "pattern"
+
+	:g/pattern/?^$?+,//-s/^/#
+
+#### Sort content of multiline CSS blocks
+
+	:g/{$/+,/^}/-!sort
+
+#### Sort content of multiline CSS blocks (media queries)
+
+	:g/^[^@].*{$/+,/}/-!sort
+
+#### Reformat HTML paragraphs to a fixed width (40)
+
+	:g/<p>/+,/<\/p>/-!fmt -40
+
+#### Swap "Lastname, Firstname" to "Firstname, Lastname"
+
+	:%s/\(.*\), \(.*\)/\2 \1
+
 #### Join all lines
 
 	:%j
 
+#### Copy (t) or move (m) lines containing "pattern"
+
+	:g/pattern/t$
+	:g/pattern/m$
+
 #### Select a column (3rd) from formated text seperated by ':' 
 
 	:%!awk -F':' '{print $3}' 
 
+#### Insert the sum of a list of numbers after an arbitrary number of lines
 
+	1) mark the first line: mk
+	2) mark the last line: ml
+	:'k,'l!awk 'END{print "Total:", i}{i+=$1; print}'
+
+	More compact version:
+	:'k,'l!awk 'END{print "Total:", i} ++i || 1'
+
+#### Email the current paragraph
+
+	:?^$?+,//-w !mail -s "<subject>" email@example.com