vim-dentures icon indicating copy to clipboard operation
vim-dentures copied to clipboard

Inconsistency with repeated motion

Open chaoren opened this issue 8 years ago • 6 comments

Let ( ) denote the cursor position and [ ] denote visual selection.

Consider this behavior of word objects:

f(o)o bar -> viw -> [fo(o)] bar -> iw -> [foo( )]bar -> iw -> [foo ba(r)]
f(o)o bar -> v3iw -> [foo ba(r)]
f(o)o bar baz -> vaw -> [foo( )]bar baz -> aw -> [foo bar( )]baz -> aw -> [foo bar ba(z)]
f(o)o bar baz -> v3aw -> [foo bar ba(z)]

By analogy, your plugin should behave like this:

^f(o)o$           [^foo($)]          [^foo$          [^foo$
^$      -> vii ->  ^$       -> ii ->  ^($)] -> ii ->  ^$
^bar$              ^bar$              ^bar$           ^bar($)]

^f(o)o$            [^foo$
^$      -> v3ii ->  ^$
^bar$               ^bar($)]

^f(o)o$           [^foo$            [^foo$          [^foo$
^$                 ^($)]             ^$              ^$
^bar$   -> vai ->  ^bar$   -> ai ->  ^bar$ -> ai ->  ^bar$
^$                 ^$                ^($)]           ^$
^baz$              ^baz$             ^baz$           ^baz($)]

^f(o)o$            [^foo$
^$                  ^$
^bar$   -> v3ai ->  ^bar$
^$                  ^$
^baz$               ^baz($)]

chaoren avatar Feb 17 '16 06:02 chaoren

Whoops, accidentally duplicated with https://github.com/qstrahl/vim-dentures/issues/1, but I spent so much time on the examples...

chaoren avatar Feb 17 '16 07:02 chaoren

I'll close #1 in favour of this one, since you put so much effort into it and @tommcdo is a ninny.

qstrahl avatar Feb 17 '16 18:02 qstrahl

:(

tommcdo avatar Feb 17 '16 18:02 tommcdo

@qstrahl any chance this plugin will be extended so that a visual selection can grow?

kiryph avatar Nov 22 '17 12:11 kiryph

@kiryph I've always planned to fix it, but I haven't found the time - plus, thinking about these text objects for very long makes my head spin. :P

I would happily welcome a patch... otherwise I'm afraid you're stuck on my "when I feel like it" schedule.

qstrahl avatar Nov 22 '17 22:11 qstrahl

@qstrahl Thanks for the quick feedback.

I guess I picked the wrong time of the year to ping someone to hope to get him to add a great missing feature 😇.

I am actually using https://github.com/michaeljsmith/vim-indent-object which can grow a visual selection. However, I've always been unsure what the best definition for a text object for indentation should be.

The definition of michaeljsmith/vim-indent-object is:

        <count>ai         (A)n (I)ndentation level and one line above.
        <count>ii         (I)nner (I)ndentation level (no line above).
        <count>aI         (A)n (I)ndentation level and one line above and one below.
        <count>iI         (I)nner (I)ndentation level (no lines above/below).

I am not unhappy with it, but e.g. vai to select a python method with decorators does not select the decorator which makes me feel like ai is not flexible enough:

class Parrot:
    def __init__(self):
        self._voltage = 100000

    @property
    def voltage(self):
        """Get the current voltage."""
        return self._voltage

screen shot 2017-11-23 at 10 37 25

I think your definition based on optionally including blank lines could be a more flexible approach. I could imagine something like iIii with your plugin.

kiryph avatar Nov 23 '17 09:11 kiryph