Skip to content

Commit a613da2

Browse files
committed
Updated README
1 parent 65e9bb7 commit a613da2

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22

33
Sublime Text 3 plugin - inline python evaluation.
44

5+
## Functionality
6+
7+
### As a calculator
8+
59
For example you can write 3.14*0.6 and get the result (1.884) in your text.
610
It also supports multiple selection.
711

12+
### Incremnt counter at cursor positions
13+
814
Another feature is the use of $ as accumolation variable, e.g. having the following multipe selection:
915

1016
arr[$]
1117
arr[$]
1218
arr[$]
1319

14-
will result with
20+
will result with
1521

1622
arr[1]
1723
arr[2]
@@ -23,6 +29,69 @@ similarly:
2329
arr[$+2] -> arr[3]
2430
arr[$*3] arr[6]
2531

32+
### General Python evalueator
33+
34+
Besides that, you have the following imports avaiable:
35+
36+
from math import *
37+
from random import *
38+
from collections import Counter
39+
import datetime
40+
import re # though you should probably use the build in regex features of ST instead.
41+
42+
So you can do:
43+
44+
Counter(('Ann', 'Bob', 'Bob', 'Michael')) = Counter({'Bob': 2, 'Ann': 1, 'Michael': 1})
45+
Counter(('Ann', 'Bob', 'Bob', 'Michael', 'michael')) = Counter({'Bob': 2, 'Ann': 1, 'michael': 1, 'Michael': 1})
46+
Counter(name.title() for name in ('Ann', 'Bob', 'Bob', 'Michael', 'michael')) = Counter({'Bob': 2, 'Michael': 2, 'Ann': 1})
47+
48+
### Computing checksums
49+
50+
And the functions `md5` and `sha1` returns the correspondingly hex-digest of the stringified version of the inputs, e.g. `md5(['foo', 'bar', 'baz']) = dbb432a3f0ac1a2687911715dfbf7502`. Notice that it's possible to hash the list _because it's the string-representation of the list which are being hashed!_
51+
52+
The python `hashlib.md5` and `hashlib.sha1` functions are avaiable under the names `_md5` and `_sha1`.
53+
54+
### Inserting datatimes
55+
56+
The functions `dnow`, `tnow` and `dtnow` return respectively the current string-formatted date, time and datetime:
57+
58+
dnow() = 03/05/2017
59+
tnow() = 09:36:03
60+
dtnow() = 03/05/2017 09:36:03
61+
62+
Notice that you need to have parenthesis after the function name to invoke the function call.
63+
64+
### Formatting numbers
65+
66+
The fnuction `formatnum` formats numbers, and takes two mandatory and an optional argument:
67+
68+
num
69+
: The number bieng formatted.
70+
71+
digits
72+
: The number of desired digits in the formatted number.
73+
74+
scientificNotation
75+
: Wether of not to use scientific notation.
76+
: Can be True, False or int, where int is the threshold for how many characters the number may contain when formatted un-scientifically, before switching to scientific notation.
77+
: This is the default behaviour, and it's set to 8.
78+
79+
Example usage:
80+
81+
formatnum(0.123456789, 4) = 0.1235
82+
formatnum(0.123456789, 9) = 1.234567890e-01
83+
formatnum(123456789.0, 9) = 1.234567890e+08
84+
formatnum(123456789.0, 2) = 1.23e+08
85+
formatnum(123.456789, 12) = 1.234567890000e+02
86+
formatnum(123.456789, 12, False) = 123.456789000000
87+
formatnum(123.456789, 3) = 123.457
88+
formatnum(3.14159, 4) = 3.1416
89+
formatnum(3.14159, 3) = 3.142
90+
formatnum(3.14159, 2) = 3.14
91+
formatnum(3.14159, 2, True) = 3.14e+00
92+
formatnum(3.141592653589793238462643383279502884197169399375105820974944, 3) = 3.142
93+
94+
2695
## Usage
2796

2897
To evaluate term, highlight and:

0 commit comments

Comments
 (0)