About: Align numbers at decimal point   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

You want to have them nice aligned with 5 decimals written out. First, we align any line left to the beginning: :%s§^\s*§§ 123 2.5678 -13.44 100.5 +47.11 Now we split at the decimal-point (if any) and shift the fractional part wide to the right and add five '0' at the end (because we want 5 fractional digts). :%s§\([-+]\?\d\+\)\.\?\(\d*$\)§\1 !\200000§ 123 !00000 2 !567800000 -13 !4400000 100 !500000 +47 !1100000 This tricky substitue aligns the fractional part at column 15: :%s§\%15c\s*!§!§ 123 !00000 2 !567800000 -13 !4400000 100 !500000 +47 !1100000 Finally we add a '+'-sign where it's missing:

AttributesValues
rdfs:label
  • Align numbers at decimal point
rdfs:comment
  • You want to have them nice aligned with 5 decimals written out. First, we align any line left to the beginning: :%s§^\s*§§ 123 2.5678 -13.44 100.5 +47.11 Now we split at the decimal-point (if any) and shift the fractional part wide to the right and add five '0' at the end (because we want 5 fractional digts). :%s§\([-+]\?\d\+\)\.\?\(\d*$\)§\1 !\200000§ 123 !00000 2 !567800000 -13 !4400000 100 !500000 +47 !1100000 This tricky substitue aligns the fractional part at column 15: :%s§\%15c\s*!§!§ 123 !00000 2 !567800000 -13 !4400000 100 !500000 +47 !1100000 Finally we add a '+'-sign where it's missing:
Version
  • 5(xsd:double)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 892(xsd:integer)
Category
  • Usage
Author
  • Michael Fitz
Complexity
  • intermediate
Created
  • 2005(xsd:integer)
ID
  • 893(xsd:integer)
NEXT
  • 894(xsd:integer)
Rating
  • 3(xsd:integer)
abstract
  • You want to have them nice aligned with 5 decimals written out. First, we align any line left to the beginning: :%s§^\s*§§ 123 2.5678 -13.44 100.5 +47.11 Now we split at the decimal-point (if any) and shift the fractional part wide to the right and add five '0' at the end (because we want 5 fractional digts). :%s§\([-+]\?\d\+\)\.\?\(\d*$\)§\1 !\200000§ 123 !00000 2 !567800000 -13 !4400000 100 !500000 +47 !1100000 This tricky substitue aligns the fractional part at column 15: :%s§\%15c\s*!§!§ 123 !00000 2 !567800000 -13 !4400000 100 !500000 +47 !1100000 Now we shift the integral part back by exchanging it with leading spaces (and replacing '!' by decimal-point): :%s§\(^\S*\)\(\s*\)!§\2\1.§ 123.00000 2.567800000 -13.4400000 100.500000 +47.1100000 Now we truncate each fractional part to 5 digits: :%s§\%21c\d*§§ 123.00000 2.56780 -13.44000 100.50000 +47.11000 Finally we add a '+'-sign where it's missing: :%s§\s\(\d\)§+\1§ +123.00000 +2.56780 -13.44000 +100.50000 +47.11000 I usually use the (german) paragraph-sign '§' to surround the substitute-patterns, because this letter is very seldom used in any IT-related context.
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software