On Fri, Mar 11, 2016 at 08:08:38PM +0100, Marc André Tanner wrote:
> On Tue, Mar 01, 2016 at 05:23:11PM +0000, Connor Lane Smith wrote:
> > On 1 March 2016 at 17:12, Marc André Tanner <mat_AT_brain-dump.org> wrote:
> > > I think structural regexp will integrate nicely with multiple selections.
> > >
> > > Basically if you omit the command of a structural regexp the editor
> > > would switch to visual mode and add a selection for every match. If you
> > > are already in visual mode then the existing selections would be used
> > > as ranges for an implicit leading loop construct (x/ in sam).
> > > That is for an existing selection x/ and y/ could be used to split it.
> > > Similarly the conditionals g/ and v/ would be used to keep / discard
> > > selections.
> >
> > I agree (strongly!). My main complaint with sam is its inability to
> > reflect the multiple selections implied by its command language. It
> > would be fantastic if we could get that sorted, and vis may well be a
> > good place to do it.
>
> I finally had some time to experiment with these ideas.
In the meantime lots of bugs have been fixed. I would like to encourage
all sam/acme users who are also somewhat familiar with vi(m) to try out
current master of vis and report back on their experience:
https://github.com/martanne/vis
http://repo.or.cz/w/vis.git
Some differences compared to sam (see also the man page[1]):
* Multiple "dots" (selections) can exist simultaneously.
* Commands can be interactively refined, whenever sam would invoke the
print command vis instead creates a selection matching the corresponding
range. If no selection remains after a command execution, vis switches
to normal mode. Otherwise it stays in visual mode.
* Changes do not need to be in sequence, but only non-overlapping i.e.
the following works as expected:
:x/Emacs/ { d i/V/ a/i/ }
* The s (substitute) command was dropped. Instead :x/pattern/c/replacement/
can be used for global search and replacement. The registers \1-\9 refer
to sub expression matches. & contains the complete matched text, hence:
:x/Vi/ c/>&</
has the same effect as:
:x/Vi/ { i/>/ a/</ }
Substitution of the first match (i.e. similar to s without the global
flag) can be achieved using:
:/pattern/ c/replacement/
Sam supports a count specifier: s2/pattern/replacement/ only replaces
the second occurrence of pattern. This is currently not supported but
can be mimicked using:
:/pattern/ // c/replacement/
A more general variant of the count concept might be later integrated
into the x, y and/or g, v commands. Comments and syntax suggestions
welcome.
* Besides \n for newlines, \t can be used to insert tabs.
* Searches do not wrap around at the start (end) of the file.
* Marks are valid addresses which can be referred to using 'm
There are also some problems left which could be improved:
* Case insensitive search is currently not supported. A global option
would be no problem. Integration into the command language inorder to
specify it on a per-pattern basis might be more tricky. For example
the obvious syntax introducing pattern flags (e.g. `i` for case
insensitive):
:/pattern/i
is already taken by the insert command:
:/pattern/i/text/
which denotes insertion at the start of pattern, not a case insensitive
search for pattern followed by a case sensitive search for text.
Again, comments and syntax suggestion welcome.
* Vis is currently incapable of restoring past selections once the
corresponding cursors have been disposed. That is
:x/pattern/<Enter><Escape>gv
works, but a second <Escape> (in normal mode) would get rid of the
cursors and hence also of all selections.
* There is currently no easy way to specify multi line commands. The
command prompt is implemented as a regular file. Hence <Ctrl-v><Enter>
inserts a line break without executing the command. We should probably
investigate ways to make this a bit more convenient.
* Multi file support is not really well supported:
- The X and Y commands currently operate on windows, not files.
Meaning that if a file is being displayed in multiple windows
a given command will be executed once for every window. This is
desired in certain cases (e.g. `:X q` to close all windows without
unsaved changes) and unwanted in others (e.g.
:X 0i,/* ISC licensed */\n
to add a license template to the top of every file).
- The whole undo concept is file specific, the above insertion command
can not easily be undone. Implementing an u command would at least
give the possibility to `:X u` undo all changes. vis does currently
not allow to switch windows while in visual mode.
Comments (and patches) regarding vis in general are also welcome. Either
here, in #vis-editor on Freenode or in the Github issue tracker.
I would like to do another release relatively soon. Happy editing.
Cheers,
Marc
[1]
http://martanne.github.io/vis/man/vis.1.html
Received on Thu Feb 02 2017 - 18:46:15 CET