Wacro

python

String macro operations

wacro is a commandline program that can run multiple string operations on text files.

Commands

syntax: f or find
parameters: takes a find query string as a parameter
description: finds all occurences of a find query and selects them all

# 1 - selects the ll in the word hello
main.py -i "hello dave" -c "[f=ll]"

syntax: r or replace
parameters: takes the string to overwrite selections as parameter
description: replaces all selections with a string

# 1 - selects the ll in the word hello
# 2 - replaces them with a y, giving the result "heyo dave"
main.py -i "hello dave" -c "[f=ll,r=y]"

syntax: ss or start
parameters: takes no parameters
description: This will shrink the selected region to its start position

# 1 - selects the ll in the word hello
# 2 - selects the first l
# 3 - replaces the l with a y, giving the result "heylo dave"
main.py -i "hello dave" -c "[f=ll,ss,r=y]"

syntax: se or end
parameters: takes no parameters
description: This will shrink the selected region to its last position

# 1 - selects the ll in the word hello
# 2 - selects the last l
# 3 - replaces the l with a y, giving the result "helyo dave"
main.py -i "hello dave" -c "[f=ll,se,r=y]"

syntax: ms or move
parameters: takes an amount of postions to move
description: move each selected region by a certain amount. positive numbers go right, negative numbers go left

# 1 - selects the h in the word hello
# 2 - moves the selected region to now point at the next letter,
		which is the e in the word hello
# 3 - replaces the e with a y, giving the result "hyllo dave"
main.py -i "hello dave" -c "[f=h,ms=1,r=y]"

syntax: es or expand
parameters: takes the amount of postions to expand
description: expands the selected region by a certain amount, using postive numbers will expand region, using negative number will contract region

# 1 - selects the ll in the word hello
# 2 - expands the selected region to now include the e before the ll
		and the o that leads the ll
# 3 - replaces the ello with a i, giving the result "hi dave"
main.py -i "hello dave" -c "[f=ll,es=1,r=i]"

syntax: fi or inside
parameters: takes a find query string as a parameter
description: finds all occurences of a find query in all selected regions and selects them all

# 1 - selects the word hello
# 2 - selects the ll in the word hello
# 3 - replaces them with a y, giving the result "heyo dave"
main.py -i "hello dave" -c "[f=hello,fi=ll,r=y]"

syntax: sl or line
parameters: takes no parameters
description: selects the whole line of each selected region

# 1 - selects the word how
# 2 - selects the whole line where how is located
# 3 - replaces the whole line with sup, giving the result "hello dave\nsup"
main.py -i "hello dave\nhow are things" -c "[f=how,sl,r=sup]"

syntax: ps or print_selection
parameters: takes no parameters
description: prints the current selection to console

# 1 - selects the word how
# 2 - prints out the word how
# 3 - selects the whole line where how is located
# 4 - prints out the whole line how are things
# 5 - replaces the whole line with sup, giving the result "hello dave\nsup"
main.py -i "hello dave\nhow are things" -c "[f=how,ps,sl,ps,r=sup]"