Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency with repeated motion #7

Open
chaoren opened this issue Feb 17, 2016 · 6 comments
Open

Inconsistency with repeated motion #7

chaoren opened this issue Feb 17, 2016 · 6 comments
Labels

Comments

@chaoren
Copy link

chaoren commented Feb 17, 2016

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
Copy link
Author

chaoren commented Feb 17, 2016

Whoops, accidentally duplicated with #1, but I spent so much time on the examples...

@qstrahl
Copy link
Owner

qstrahl commented Feb 17, 2016

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

@tommcdo
Copy link

tommcdo commented Feb 17, 2016

:(

@qstrahl qstrahl added the bug label Feb 18, 2016
@kiryph
Copy link

kiryph commented Nov 22, 2017

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

@qstrahl
Copy link
Owner

qstrahl commented Nov 22, 2017

@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.

@kiryph
Copy link

kiryph commented Nov 23, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants