visual mode is weird

Bug #640097 reported by Stefan Bethge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ViGedit
Triaged
Undecided
Unassigned

Bug Description

I really like the plugin, but it is still a bit incomplete. Especially selecting things in visual mode behaves quite odd.
I would expect to be able to press v and then select things with the cursor keys.
The status bar says I'm in visual mode, but nothing else happens when moving around. Holding shift allows to select things
but I can't delete with d or yank with y (x works though).
Similarly, selecting lines with shift-v does not select the full first line but just up to where the cursor is.
Also, when something is selected, using ex mode doesn't work on the line range as expected but deselects things again.
I often use this to search and replace things in a few lines (with a regexp).

(I thought about putting all of these in separate tickets but I guess it is one group of problems that can go together.)

Revision history for this message
Stephen Moore (delfick) wrote :

Hello,

I agree, It definitely is very much incomplete from a comparison against vim itself point of view :p

However, the plugin doesn't always try to imitate vim exactly.

This is one of those cases. In visual mode, the cursor keys move the cursor, the only keys that actually select are jkl and l

in visual mode, y does yank
I've added d with this commit, http://bazaar.launchpad.net/~delfick/vigedit/vigedit-additions/revision/80

As for the ex mode problem, I'm not sure what you mean (I learned most of what I know of vim through making this plugin, so I'm not familiar with quite a lot :p), can you explain a bit more please ? (and in a separate ticket please :))

Thankyou for your bug reports :D

Revision history for this message
Stephen Moore (delfick) wrote :

Oh, and forgot to mention, Shift+V selects the entire line for me no matter where the cursor is...

Do you have an example piece of text and where your cursor is when you press Shift+V where this bug comes up ?

Revision history for this message
Stefan Bethge (kjyv) wrote :

Hello :)

Thanks for fixing some things so quickly. I understand that the plugin can't imitate vim completely (which would far exceed my vim knowledge as well) but it would be nice if it could provide basic tools that I started to like in vim. I'll create that other ticket and maybe you will learn a feature more by it :)

I guess it's easy to add the cursor keys to do the same hjkl does (I can try to do it too) and I see that it yanks and deletes (now). Great so far. One thing that remains: with d or x, the mode is returned to command mode while yanking stays in visual mode. Should be command as well. (and maybe something like vim does, put something like 'x lines yanked' would be nice :) )
Also I think there is a problem with visual mode and then undo not working, I'll look into that more and create another ticket.

V selects the full line the cursor is on. So far thats fine.

Lets take some code:

class MODE_options(object):
    """Options object for this mode"""
    def __init__(self, act, options=None):
        self.lastCommand = None
        self.history = []
        self.index = -1

Having the cursor on position 0 in the first line, pressing V, it selects the full line. Then pressing j, the next line is selected until the h of 'this', so directly under the colon, which is probably where the cursor was before. Hope that helps?

Thank you for the plugin ;)

Revision history for this message
Stephen Moore (delfick) wrote :

Making the cursor keys continue the selection in visual mode, means adding
        self.reg(act.pos.move_Forward, act.gtk.keysyms.Right, **self.fr)
        self.reg(act.pos.move_Backward, act.gtk.keysyms.Left, **self.fr)
        self.reg(act.pos.move_Down, act.gtk.keysyms.Down, **self.fr)
        self.reg(act.pos.move_Up, act.gtk.keysyms.Up, **self.fr)

to /bindings/visual.py/Mode/setup

but I like it's current behaviour, so I won't, sorry :p
(One day I'll think of a way to make this kind of stuff easily customizable)

As for the behaviour you expect from Shift+V, the reasons for this is that this command doesn't set any flag anywhere that says to select lines.

I'm sure it's possible to do, but it will require a bit of thinking...

Changed in vigedit:
status: New → Triaged
Revision history for this message
Stefan Bethge (kjyv) wrote :

Having local modifications isn't really nice, so yes, having customization seems really necessary :) Since you like to have a few things different than standard vim, maybe something like a vim compatibility mode would be nice. It seems there is a button to configure a plugin in the plugin dialog, so that would be a good place to add options.
I see the issue about shift-v isn't that easy... myabe the mode can have additional flags (seeing its a class, is the current mode an object that stays as long as the mode stays? maybe it just needs a parameter about line selection).

(i hope you don't feel pushed by the bugs and comments I put here. No problem if you got other stuff to do)

Revision history for this message
Stephen Moore (delfick) wrote :

The problem isn't so much setting the flag, as much as making it have different behaviour.

Basically there's these choices
1) Make a wrapper function that acts as the bindings, which chooses what function to call when the keybinding is activated
2) Make the functions that are already called aware of this setting (these functions are completely separate, so that could potentially be a bad idea
3) Make the class swap the functions when the flag is set, which would require another layer of complexity for registering functions.
4) Some other method that isn't on the top of my head :p

As for configuring the plugin :
1) User interface, both in terms of I'm not sure how to use gtk, and not how the interface would look
2) Would probably require a bit of re-architecturing of how the keybindings are currently registered

I would rather have some kind of system setup where all provided functionality for plugins is made up by many small, atomic functions along with some nice way of 'building' them into nice things.

but that would take quite a bit of time :(

Whereas, currently, there aren't many functions and they're all slightly hacky. (infact, despite the fact that the plugin has been rewritten twice, most of it is a bit hacky (each time I rewrote the plugin, it seemed elegant because it matched the programming level I was at, which is a bar that keeps rising :p)

> i hope you don't feel pushed by the bugs and comments I put here.

no, but I do have a bad habit of procrastinating on things like this :p

Revision history for this message
Stefan Bethge (kjyv) wrote :

Actually, vim has a separate mode for this. In Vim there are visual, visual line and visual block modes. Creating a new mode in ViGedit that would be triggered on shift-v would probably not raise the issues you mentioned. I guess that would allow us to bin to different methods like

For the cursor keys, there are more things to do to make them work. I really wonder though in what way you like the way it currently is. Do you mean aborting visual mode when you press the keys? Otherwise the behaviour stays the same with all the rest of the key bindings. I've removed the cursor keys and home/end from the ignore list in static and added bindings to the modes. I'll add a patch to a new ticket when I'm happy with it.

Revision history for this message
Stefan Bethge (kjyv) wrote :

sorry, it's late:

... would allow us to bind to different methods like move_Up_Lines or similar.

Revision history for this message
Stefan Bethge (kjyv) wrote :

I now created a branch with a few of the things in there with a visual line mode thats almost very nice. I might add some more things there.

Revision history for this message
Stephen Moore (delfick) wrote :

Awesome, thnx, when I have time I'll have a look and merge....

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.