-
Notifications
You must be signed in to change notification settings - Fork 50
Altering words
Normally, words coming from stdin or a file are displayed as is.
When this is not desired smenu offers the option to alter them
with the -S
, -I
or -E
command line options.
In the following examples only the unconditional substitution option
(-S
) will be used.
Two general possibilities are offered:
- A destructive one: if an altered word is selected, then this modified form will be selected, This is the default.
- A non destructive one: in this case, the altered form will only be used for display and if selected, the original word will be put in the selection instead.
The non destructive one must be explicitly specified by adding the v
toggle to one of the above options. v
stands for virtual.
Here are some example showing the difference:
Normal substitution of a
by #
:
smenu -S/a/#/
Substitution using the v
toggle, note the resulting value of the
R
variable in the following example.
smenu -S/a/#/v
The v
toggle need to only appear once in the suite of substitutions
and impacts all the substitution:
smenu -S/a/#/v -S/b/@/
smenu -S/a/#/ -S/b/@/v
The g
toggle is similar to the one used in sed, it means
global and alters all the instances found in the word and not only
the first one. This gives:
smenu -S/a/#/g
The i
toggle means ignore case:
smenu -S/a/#/i
All the toggles can be combined, here is an example with gvi
:
smenu -S/a/#/gvi
The s
toggle means single and is a little more complicated
to understand. Its objective is to only allow one modification in words
even if another substitution is requested:
Without:
smenu -S/a/#/ -S/a/@/
With:
smenu -S/a/#/s -S/a/@/
Another example:
smenu -S/a/#/s -S/b/@/s -S/b/_/
smenu illustrated concepts and examples: