Differences from Sam - martanne/vis GitHub Wiki
Below we list some deliberate differences in behavior compared to sam and/or acme.
We support multiple "dots" (or ranges, selections) at the same time, enabling a more interactive experience. In sam the following two independent commands run one after another
,x/pattern
c/replacement
have the effect that x sets dot to the last occurrence of pattern which is
then subsequently replaced.
Whereas in vis the x commands creates a new selection for every occurrence of
pattern and switches to visual mode. If the change command c is later executed
it affects all selections.
Commands within groups (braces) do not have to appear on separate lines.
x/Emacs/ { i/>/ a/</ } is valid syntax.
x/Emacs/ { d i/V/ a/i/ } works as expected.
In vis ^ and $ always match the beginning / end of the range they are applied to.
This differs from sam where they only match the beginning / end of a line.
Rob Pike writes on this topic in his
Structural Regular Expressions paper:
The program to capitalize ‘i’s should be writable as
x/[A-Za-z]+/ g/^i$/ c/I/
That is, the definition of ^ and $ should reflect the structure of the input.
For compatibility and because of some problems in the implementation, however,
^ and $ in sam always match line boundaries.
The above command works as expected in vis.
Use /pattern/ c/replacement/ to substitute the first,
/pattern/ // c/replacement to change the second or
x/pattern/ c/replacement/ to replace all matches.
Sam's substitute command supports an explicit count specifier: s3/pattern/replacement/
indicates that only the third occurrence of pattern should be substituted.
In vis a more generalized variant of the same concept has been integrated
into the g and v commands.
The equivalent of the above sam command is x/pattern/ g3 c/replacement/.
The text given for the a, i and c commands can optionally be prefixed
with a count specifier, indicating how many times it should be inserted.
These refer to the corresponding register values capturing the (sub) expression
matches of the last performed search. & contains the complete matched text.
Hence, x/Vi/ c/>&</ has the same effect as x/Vi/ { i/>/ a/</ }.
And x/(.)-(.)/ c/\2-\1/ applied to o-O results in O-o.
In addition to \n for newlines, \t can be used to specify literal tab characters.
'm where m denotes one of the vi marks
can be used as an address.
Currently searches with +/pattern, -/pattern do not wrap around at the
end (start) of the file.
Sam has a dedicated command window, whereas in vis' command prompt multi-line commands
need to be entered using <Ctrl-v><Enter>.
Commands for functionality covered by traditional vi keybindings are not implemented.
Examples include: m (move), t (copy), k (set mark) and u undo.
While the commands X and Y are recognized, multi-file support is not yet well supported
and will need further design work.
See also issue #219 and the mailing list discussion.
The mouse is currently not used at all.
Changes of external commands < and | are only applied if they exit with success. Append || true to the command to match the sam behavior of using the output irrespective of exit status.