Tuesday, November 22, 2011

Re: Change text-object from start of line

On Nov 21, 10:09 pm, Nathan Neff <nathan.n...@gmail.com> wrote:
> I like the ci" feature in Vim, especially how
> you can type ci" from *outside* a quoted string.
>
> Vim figures out that I want to change the contents
> of the first quoted string on the line.  But, Vim only does
> this for single quotes and double quotes.  Why is that?
>
> For example, if my cursor is at ">" below,
> and I type ci" then this:
>
> >He said "Hello World"
>
> becomes this:
>
> He said ""
>
> But, if I have this line:
>
> >He said (Hello World)
>
> and I type ci( to change the contents of the parens,
> the cursor remains at the start of the line.
>
> Can I get Vim to treat parens, "<" etc the same as it
> does with quotes when the cursor is outside the quotes?.
>

It may be because quotes of all kinds are the only multi-word text
objects which cannot span multiple lines. Additionally, in general,
such quotes do not nest. With these two limits, it is easy to pick out
the item of interest in a line. But if the object can extend multiple
lines, and can nest, it is not at all easy to discern the intent.

Consider:

abc(
def(1,2,3)
ghi(4))

Placing the cursor on the 'd' and trying to operate on an ab object
currently (and correctly) gets all three lines. But trying to make Vim
guess whether you really meant this, or the block on the line itself,
would be difficult and/or confusing to users.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: