Procedural Text Edit 1.0.0 - Documentation
Usage examples
//C++ change to override syntax
forEach line {
    if (and (contains cs "virtual") (not (endsWith cs "0;"))) {
        findRemove cs "virtual "
        findRemove cs ";"
        append " override;"
    }
}
+
class Foo : public Base {
    virtual void foo() = 0;

    virtual void bar();

    void baz();
};
V
class Foo : public Base {
    virtual void foo() = 0;

    void bar() override;

    void baz();
};

//C++ add const qualifiers if reference
forEach line {
    select (between cs "(" ")") {
        forEachSplitAt cs "," {
            if (and (contains cs "&") (not (contains cs "const"))) {
                select (before cs "&") {
                    append " const"
                }
            }
        }
    }
}
+
void foo(int i, Baz& baz, const Bar);

void bar(Car& c, Dog const& d);

void baz(double d, Struct s, Window& w);

V
void foo(int i, Baz const& baz, const Bar);

void bar(Car const& c, Dog const& d);

void baz(double d, Struct s, Window const& w);


//cleanup of duplicates and sorting
removeEmptyLines
removeAnyDupe line
sort line cs

//styling
forEach line {
    select (firstN char 1) {
        toUpper
    }

    prepend "[ ] "
}
+
milk
pizza
dog food

cat food
milk
apples
bananas
dog food
water

milk
V
[ ] Apples
[ ] Bananas
[ ] Cat food
[ ] Dog food
[ ] Milk
[ ] Pizza
[ ] Water

Target: Specifies whether actions should be applied per char, word or line
char
Used to apply actions per char
reverse char
+
hello world
goodbye moon
>
noom eybdoog
dlrow olleh

line
Used to apply actions per line
reverse line
+
hello world
goodbye moon
>
goodbye moon
hello world

word
Used to apply actions per word
reverse word
+
hello world
goodbye moon
>
moon goodbye
world hello

CaseSensitivity: Specifies whether actions should be case sensitive (cs) or case insensitive (ci)
ci
Used to apply actions case insensitive
sort char ci
+
abCde
>
abCde

cs
Used to apply actions case sensitive
sort char cs
+
abCde
>
Cabde

Action: Define what should happen with the text
acos
Applies acos to the input if it's a number
acos
+
0.5
>
1.0471975511965979

acosh
Applies acosh to the input if it's a number
acosh
+
1.5
>
0.9624236501192069

add
double
Adds x to the input if it's a number
add 4.2
+
1.3
>
5.5

alignLinesAtLeft
string
Aligns the lines to the left at occurences of the search
alignLinesAtLeft "="
+
double d = 4.0;
int i = 3;
FooBarBaz fooBarBaz = nullptr;
>
double d            = 4.0;
int i               = 3;
FooBarBaz fooBarBaz = nullptr;

alignLinesAtNthWordLeft
int
Aligns the lines to the left at the nth word
alignLinesAtNthWordLeft 1
+
let's align
ratherlongword is
hello world
>
let's          align
ratherlongword is
hello          world

alignLinesAtNthWordRight
int
Aligns the lines to the right at the nth word
alignLinesAtNthWordRight 1
+
let's align
ratherlongword is
hello world
>
         let's align
ratherlongword is
         hello world

alignLinesAtRight
string
Aligns the lines to the right at occurences of the search string
alignLinesAtRight "="
+
double d = 4.0;
int i = 3;
FooBarBaz fooBarBaz = nullptr;
>
           double d = 4.0;
              int i = 3;
FooBarBaz fooBarBaz = nullptr;

alignTo
int
Prepends or removes spaces until there's n spaces
forEach line {alignTo 3}
+
         hello world
 hello moon
     hello sun
>
   hello world
   hello moon
   hello sun

append
string
Appends the provided string to the input
append " world"
+
hello
>
hello world

appendLine
Appends an empty line
appendLine
+
hello world
>
hello world


asin
Applies asin to the input if it's a number
asin
+
0.5
>
0.5235987755982989

asinh
Applies asinh to the input if it's a number
asinh
+
0.5
>
0.48121182505960347

atan
Applies atan to the input if it's a number
atan
+
0.5
>
0.4636476090008061

atanh
Applies atanh to the input if it's a number
atanh
+
0.5
>
0.5493061443340549

ceil
Applies ceil to the input if it's a number
ceil
+
1.2
>
2

collapseLines
Fuses lines together, leaving spaces in-between
collapseLines
+
hello world
second line
>
hello world second line

collapseWords
Removes any whitespaces and merges the words together
collapseWords
+
hello world
second line
>
helloworldsecondline

copyNthBwdBy
target int int
Copies the nth char/word/line backward by n
copyNthBwdBy word 3 1
+
hello dear world and moon
>
hello dear and world and moon

copyNthFwdBy
target int int
Copies the nth char/word/line forward by n
copyNthFwdBy word 1 2
+
hello dear world and moon
>
hello dear world and dear moon

cos
Applies cos to the input if it's a number
cos
+
2
>
-0.4161468365471424

cosh
Applies cosh to the input if it's a number
cosh
+
0.5
>
1.1276259652063807

divideBy
double
Divides the input by x if it's a number
divideBy 2.0
+
3.1
>
1.55

divideFrom
double
Divides x by the input if it's a number
divideFrom 3.1
+
2.0
>
1.55

drop
target int
Removes the first n chars/words/lines
drop char 3
+
hello world
>
lo world

dropRange
target int int
Starting from offset it drops n chars/words/lines and keeps the rest
dropRange char 1 3
+
hello world
>
ho world

dropRight
target int
Removes the last n chars/words/lines
dropRight char 3
+
hello world
>
hello wo

enumerate
target string int
Enumerates each char/word/line starting at provided int, using the given delimiter
enumerate char "-" 2
+
abcdefg
>
2-a3-b4-c5-d6-e7-f8-g

exp
Applies the exponent function to the input if it's a number
exp
+
2
>
7.38905609893065

filter
target (condition)
Filters chars/words/lines with the given condition
filter char (number)
+
ab12c3d4
>
1234

findRemove
caseSensitivity string
Finds and removes a given string
findRemove cs "world"
+
hello my world
>
hello my 

findReplaceAll
caseSensitivity string string
Finds and replaces all occurences of the first given string with the second
findReplaceAll cs "world" "moon"
+
hello world my world
>
hello moon my moon

findReplaceFirst
caseSensitivity string string
Finds and replaces the first occurence of the first given string with the second
findReplaceFirst cs "world" "moon"
+
hello world my world
>
hello moon my world

findReplaceLast
caseSensitivity string string
Finds and replaces the last occurence of the first given string with the second
findReplaceLast cs "world" "moon"
+
hello world my world
>
hello world my moon

floor
Applies floor to the input if it's a number
floor
+
1.9
>
1

forEach
target {actions}
Applies actions char/word/line wise
forEach char {append "-"}
+
hello
>
h-e-l-l-o-

forEachBlock
{actions}
Applies actions block wise (separated by empty lines)
forEachBlock {append "x"}
+
hello world
goodbye moon

howdy sun
>
hello world
goodbye moonx

howdy sunx

forEachIndexed
target [int] {actions}
Applies actions for each char/word/line which has the same index as given in the list
forEachIndexed char [2 4 5 6] {toUpper}
+
someverylongword
>
soMeVERylongword

forEachIndexedSplitAt
caseSensitivity string [int] {actions}
Applies actions for each split at a given string which has the same index as given in the list
forEachIndexedSplitAt cs "," [2 3 6 8] {toUpper}
+
so,m,e,v,e,ryl,ong,wo,r,d
>
so,m,E,V,e,ryl,ONG,wo,R,d

forEachNth
target int int {actions}
Applies actions for each word/char/line with index defined by nth and offset
forEachNth char 2 3 {toUpper}
+
someverylongword
>
somEvErYlOnGwOrD

forEachNthSplitAt
caseSensitivity string int int {actions}
Applies actions for split at a given string with index defined by nth and offset
forEachNthSplitAt cs "," 2 3 {toUpper}
+
so,m,e,v,e,ryl,ong,wo,r,d
>
so,m,e,V,e,RYL,ong,WO,r,D

forEachSplitAt
caseSensitivity string {actions}
Applies actions for each split at a given string
forEachSplitAt ci "D" {append "x"}
+
hello world
goodbye moon
>
hello worlxd
gooxdbye moonx

if
(condition) {actions}
Applies actions if the provided condition is true
forEach word { if (contains cs "a") {toUpper} }
+
aa cat dog aaa
>
AA CAT dog AAA

ifAll
target (condition) {actions}
Applies actions if the condition is true for all chars/words/lines of the input
forEach word { ifAll char (upper) {toLower} }
+
Cat dOG HOUSE
>
Cat dOG house

ifAny
target (condition) {actions}
Applies actions if the condition is true for any char/word/line of the input
forEach word { ifAny char (upper) {toUpper} }
+
cat dOg house
>
cat DOG house

ifElse
(condition) {actions} {actions}
Applies the first actions if the provided condition is true, otherwise the other actions
forEach word { ifElse (contains cs "a") {toUpper} {remove} }
+
aa cat dog aaa
>
AA CAT  AAA

ifElseAll
target (condition) {actions} {actions}
Applies the first actions if the condition is true for all chars/words/lines of the input, otherwise the other actions
forEach word { ifElseAll char (upper) {toLower} {remove} }
+
Cat dOG HOUSE
>
  house

ifElseAny
target (condition) {actions} {actions}
Applies the first actions if the condition is true for any char/word/line of the input, otherwise the other actions
forEach word { ifElseAny char (upper) {toUpper} {remove} }
+
cat dOg house
>
 DOG 

ifElseSelection
(selector) (condition) {actions} {actions}
Applies actions to the entire input if the provided condition is true for the selection otherwise the other actions. Does nothing if the selection is empty
forEach word { ifElseSelection (nth char 0) (upper) {toUpper} {toLower} }
+
heLLo wOrld Hello MoOn
>
hello world HELLO MOON

ifSelection
(selector) (condition) {actions}
Applies actions to the entire input if the provided condition is true for the selection
forEach word { ifSelection (nth char 0) (upper) {toUpper} }
+
hello world Hello moon
>
hello world HELLO moon

indent
int
Indents by n spaces
indent 3
+
hello world
>
   hello world

intercalate
target string
Splits by char/word/line and fuses them back together with the provided filler
intercalate word "_"
+
hello world
second line
>
hello_world_second_line

keepRange
target int int
Starting from offset it keeps n chars/words/lines and drops the rest
keepRange char 1 3
+
hello world
>
ell

log
Applies log to the input if it's a number
log
+
2
>
0.6931471805599453

moveNthBwdBy
target int int
Moves the nth char/word/line backward by n
moveNthBwdBy word 3 1
+
hello dear world and moon
>
hello dear and world moon

moveNthFwdBy
target int int
Moves the nth char/word/line forward by n
moveNthFwdBy word 1 2
+
hello dear world and moon
>
hello world and dear moon

multiply
double
Multiplies the input by x if it's a number
multiply 2.4
+
3.1
>
7.4399999999999995

negate
Negates the input if it's a number
negate
+
11.9
>
-11.9

permute
target [int]
Permutes the chars/words/lines of the input, leaving only the elements referenced by index
permute char [0 3]
+
hello world
>
hl

prepend
string
Prepends the provided string to the input
prepend "hello "
+
world
>
hello world

prependLine
Prepends an empty line
prependLine
+
hello world
>

hello world

remove
Removes the entire input
remove
+
hello
>

removeAnyDupe
target
Removes any duplicate char/word/line
removeAnyDupe char
+
hello world
>
helo wrd

removeAnyDupeAdjacent
target
Removes any duplicate adjacent char/word/line
removeAnyDupeAdjacent char
+
hello world
>
helo world

removeDupe
string
Removes any duplicate occurences of the given string
removeDupe "world"
+
hello world world hello world
>
hello world  hello 

removeDupeAdjacent
string
Removes any duplicate adjacent occurences of the given string
removeDupeAdjacent "world"
+
hello world worldworld hello world
>
hello world world hello world

removeEmptyLines
Removes empty lines
removeEmptyLines
+

hello


world
>
hello
world

repeat
string int
Repeats the input n times, placing the string in-between
repeat "--" 3
+
hello
>
hello--hello--hello

replace
string
Replaces the input with the given string
replace "world"
+
hello
>
world

reverse
target
Reverses the input
reverse char
+
hello world
>
dlrow olleh

round
Rounds the input if it's a number
round
+
1.7
>
2

select
(selector) {actions}
Applies actions to the selection result
select (after cs "a") {toUpper}
+
It rains cats and dogs
>
It raINS CATS AND DOGS

signum
Applies signum to the input if it's a number
signum
+
11.9
>
1.0

sin
Applies sin to the input if it's a number
sin
+
2
>
0.9092974268256817

sinh
Applies sinh to the input if it's a number
sinh
+
0.5
>
0.5210953054937474

sort
target caseSensitivity
Sorts ascending by char/word/line
sort char cs
+
HeLlo wOrld
>
 HLOdellorw

sortDesc
target caseSensitivity
Sorts descending by char/word/line
sortDesc char ci
+
HeLlo wOrld
>
wrOollLHed 

spacesToTabs
int
Replaces n spaces with a tab (difficult to show here)
spacesToTabs 3
+
    hello world  hello
>
     hello world  hello

sqrt
Applies the square root to the input if it's a number
sqrt
+
16
>
4.0

square
Squares the input if it's a number
square
+
3
>
9.0

subtractBy
double
Subtracts the input by x if it's a number
subtractBy 1.2
+
5.1
>
3.8999999999999995

subtractFrom
double
Subtracts the input from x if it's a number
subtractFrom 5.1
+
1.2
>
3.8999999999999995

surround
string
Surrounds the input with the given string
surround "*"
+
hello world
>
*hello world*

surround2
string string
Surrounds the input with the given start and end string
surround2 "(" ")"
+
hello world
>
(hello world)

switchCase
Switches the case of all chars (lowercase to uppercase and vice versa)
switchCase
+
HellO WorLD
>
hELLo wORld

tabsToSpaces
int
Replaces tabs with n spaces (difficult to show here)
tabsToSpaces 3
+
    hello world  hello
>
   hello world  hello

take
target int
Only keeps the first n chars/words/lines
take char 3
+
hello world
>
hel

takeRight
target int
Only keeps the last n chars/words/lines
takeRight char 3
+
hello world
>
rld

tan
Applies tan to the input if it's a number
tan
+
2
>
-2.185039863261519

tanh
Applies tanh to the input if it's a number
tanh
+
0.5
>
0.46211715726000974

toLower
Casts all chars to lowercase
toLower
+
HellO WorLD
>
hello world

toUpper
Casts all chars to uppercase
toUpper
+
HellO WorLD
>
HELLO WORLD

trimBoth
target int
Removes n char/word/line both at the start and end
trimBoth char 2
+
hello world
>
llo wor

trimEnd
target int
Removes n char/word/line at the end
trimEnd char 2
+
hello world
>
hello wor

trimSpaceBoth
Removes whitespace both at start and end
trimSpaceBoth
+
   hello world  
>
hello world

trimSpaceEnd
Removes whitespace at the end
trimSpaceEnd
+
   hello world  
>
   hello world

trimSpaceStart
Removes whitespace at the start
trimSpaceStart
+
   hello world  
>
hello world  

trimStart
target int
Removes n char/word/line at the start
trimStart char 2
+
hello world
>
llo world

truncate
Truncates the input if it's a number
truncate
+
1.7
>
1

unindent
int
Unindents by n spaces
unindent 3
+
    hello world
>
 hello world

Condition: Can be used in if statements to introduce branching
all
[(condition)]
True if all inner conditions are true
forEach word { if (all [(startsWith cs "a") (endsWith cs "c")]) {toUpper} }
+
hellc agga aggac olo
>
hellc agga AGGAC olo

and
condition condition
True if both inner conditions are true
forEach word { if (and (startsWith cs "a") (endsWith cs "c")) {toUpper} }
+
hellc agga aggac olo
>
hellc agga AGGAC olo

any
[(condition)]
True if any inner condition is true
forEach word { if (any [(startsWith cs "a") (endsWith cs "c")]) {toUpper} }
+
hellc agga aggac olo
>
HELLC AGGA AGGAC olo

contains
caseSensitivity string
True if the input contains a given string
forEach word { if (contains cs "a") {toUpper} }
+
aa cat dog aaa
>
AA CAT dog AAA

containsExact
caseSensitivity string int
True if the input contains a given string exactly n times
forEach word { if (containsExact cs "a" 1) {toUpper} }
+
aa cat dog aaa
>
aa CAT dog aaa

containsMax
caseSensitivity string int
True if the input contains a given string at most n times
forEach word { if (containsMax cs "a" 2) {toUpper} }
+
aa cat dog aaa
>
AA CAT DOG aaa

containsMin
caseSensitivity string int
True if the input contains a given string at least n times
forEach word { if (containsMin cs "a" 2) {toUpper} }
+
aa cat dog aaa
>
AA cat dog AAA

containsNumber
True if the input contains a number
forEach word { if (containsNumber) {toUpper} }
+
oneCat twoCat 3Cat
>
oneCat twoCat 3CAT

endsWith
caseSensitivity string
True if the input ends with a given string
forEach word { if (endsWith cs "a") {toUpper} }
+
aa cat doga
>
AA cat DOGA

equal
double
True if the entire input is equal to the given number
forEach word { if (not (equal 2.0)) {remove} }
+
oneCat twoCat 1.0 2.0 3.1 1.9
>
   2.0  

even
True if the entire input is an integer and it is even
forEach word { if (not (even)) {remove} }
+
oneCat twoCat 3Cat 11.2 12.3 42 43
>
     42 

greater
double
True if the entire input is greater than the given number
forEach word { if (not (greater 2.0)) {remove} }
+
oneCat twoCat 1.0 2.0 3.1 1.9
>
    3.1 

greaterEqual
double
True if the entire input is greater than or equal to the given number
forEach word { if (not (greaterEqual 2.0)) {remove} }
+
oneCat twoCat 1.0 2.0 3.1 1.9
>
   2.0 3.1 

is
caseSensitivity string
True if the entire input equals the given string
forEach word { if (is ci "aBc") {toUpper} }
+
abC ab abcd Abc ab
>
ABC ab abcd ABC ab

less
double
True if the entire input is less than the given number
forEach word { if (not (less 2.0)) {remove} }
+
oneCat twoCat 1.0 2.0 3.1 1.9
>
  1.0   1.9

lessEqual
double
True if the entire input is less than or equal to the given number
forEach word { if (not (lessEqual 2.0)) {remove} }
+
oneCat twoCat 1.0 2.0 3.1 1.9
>
  1.0 2.0  1.9

lower
True if the entire input is lower case
forEach word { if (lower) {append "1"} }
+
abc abC ABC
>
abc1 abC ABC

nExact
target int
True if the input contains exactly n chars/words/lines
forEach word { if (nExact char 2) {toUpper} }
+
aa cat doga
>
AA cat doga

nMax
target int
True if the input contains at most n chars/words/lines
forEach word { if (nMax char 3) {toUpper} }
+
aa cat doga
>
AA CAT doga

nMin
target int
True if the input contains at least n chars/words/lines
forEach word { if (nMin char 3) {toUpper} }
+
aa cat doga
>
aa CAT DOGA

negative
True if the entire input is a negative number
forEach word { if (not (negative)) {remove} }
+
oneCat twoCat 3Cat -11.2 12.3 -42 43
>
   -11.2  -42 

neither
condition condition
True if both inner conditions are false
forEach word { if (neither (startsWith cs "a") (endsWith cs "c")) {toUpper} }
+
hellc agga aggac olo
>
hellc agga aggac OLO

none
[(condition)]
True if no inner conditions are true
forEach word { if (none [(startsWith cs "a") (endsWith cs "c")]) {toUpper} }
+
hellc agga aggac olo
>
hellc agga aggac OLO

not
condition
True if the condition is false
forEach word { if (not (containsNumber)) {toUpper} }
+
oneCat twoCat 3Cat
>
ONECAT TWOCAT 3Cat

number
True if the entire input is a number
forEach word { if (number) {remove} }
+
oneCat twoCat 3Cat 43
>
oneCat twoCat 3Cat 

odd
True if the entire input is an integer and it is odd
forEach word { if (not (odd)) {remove} }
+
oneCat twoCat 3Cat 11.2 12.3 42 43
>
      43

or
condition condition
True if one of the conditions is true
forEach word { if (or (startsWith cs "a") (endsWith cs "c")) {toUpper} }
+
hellc agga aggac olo
>
HELLC AGGA AGGAC olo

positive
True if the entire input is a positive number
forEach word { if (not (positive)) {remove} }
+
oneCat twoCat 3Cat -11.2 12.3 -42 43
>
    12.3  43

startsWith
caseSensitivity string
True if the input starts with a given string
forEach word { if (startsWith cs "a") {toUpper} }
+
aa cat doga
>
AA cat doga

upper
True if the entire input is upper case
forEach word { if (upper) {append "1"} }
+
abc abC ABC
>
abc abC ABC1

xor
condition condition
True if only one of the conditions is true
forEach word { if (xor (startsWith cs "a") (endsWith cs "c")) {toUpper} }
+
hellc agga aggac olo
>
HELLC AGGA aggac olo

Selector: Used to apply actions only on specific parts of the input
after
caseSensitivity string
Selects everything after a given string
select (after cs "a") {toUpper}
+
it rains cats and dogs
>
it raINS CATS AND DOGS

afterN
target int
Selects everything after n chars/words/lines
select (afterN char 4) {toUpper}
+
it rains cats and dogs
>
it rAINS CATS AND DOGS

before
caseSensitivity string
Selects everything before a given string
select (before cs "a") {toUpper}
+
it rains cats and dogs
>
IT Rains cats and dogs

beforeN
target int
Selects everything before n chars/words/lines
select (beforeN char 5) {toUpper}
+
it rains cats and dogs
>
IT Rains cats and dogs

between
caseSensitivity string string
Selects everything between two strings
select (between cs "cats" "dogs") {toUpper}
+
it rains cats and dogs
>
it rains cats AND dogs

enclosedBy
caseSensitivity string string
Selects everything between two strings including the given delimiters
select (enclosedBy cs "cats" "dogs") {toUpper}
+
it rains cats and dogs
>
it rains CATS AND DOGS

endingWith
caseSensitivity string
Selects everything until a given string including that string
select (endingWith cs "a") {toUpper}
+
it rains cats and dogs
>
IT RAins cats and dogs

firstN
target int
Selects the first n chars/words/lines
select (firstN char 3) {toUpper}
+
it rains cats and dogs
>
IT rains cats and dogs

lastN
target int
Selects the last n chars/words/lines
select (lastN char 3) {toUpper}
+
it rains cats and dogs
>
it rains cats and dOGS

nth
target int
Selects the nth char/word/line
select (nth char 3) {toUpper}
+
it rains cats and dogs
>
it Rains cats and dogs

range
target int int
Selects a range starting at nth char/word/line spanning n char/word/line
select (range char 2 3) {toUpper}
+
it rains cats and dogs
>
it RAins cats and dogs

startingWith
caseSensitivity string
Selects everything starting with a given string
select (startingWith cs "a") {toUpper}
+
it rains cats and dogs
>
it rAINS CATS AND DOGS