Sunday, March 29, 2015

Understanding Vim exclusive motions.

Hi all,

I have just started with vim, and i need some help. This is a bit lengthy, please bear with me :).

I refer to : http://vimdoc.sourceforge.net/htmldoc/motion.html#exclusive.
Specifically, the following text:

Which motions are linewise, inclusive or exclusive is mentioned with the
command. There are however, two general exceptions:

1. If the motion is exclusive and the end of the motion is in column 1, the
end of the motion is moved to the end of the previous line and the motion
becomes inclusive. Example: `}` moves to the first line after a paragraph,
but `d}` will not include that line.

Given the following piece of text to start with:

This is just a random paragraph.

This is another random paragraph (Some text inside brackets).

This is a third paragraph.

I start with my cursor on the character `S`, just after the `(`, in the second paragraph.

I do the following commands - `d}` - in normal mode. I get the following:

This is just a random paragraph.

This is another random paragraph (

This is a third paragraph.

The cursor is now on the `(` in the second paragraph. This is expected as per the rule above: `}` is an exclusive motion, that causes the cursor to go to column 1 of the blank line between paragraphs 2 and 3; as per the rule, the cursor goes to the previous line (on the full-stop), and the motion becomes inclusive (the full-stop is deleted as part of the `d` operation).

Let's take the original text again, with the cursor again on the `S`.

If i do the following commands - `d{` - in normal mode, i would expect to get the following, because the `{` is an exclusive motion, and it causes the cursor to go to column 1 of the blank line between paragraphs 1 and 2: everything between the full-stop of paragraph 1 and the `S` are deleted, inclusive.

This is just a random paragraphome text inside brackets).

This is a third paragraph.

But what actually happens is this:

This is just a random paragraph.
Some text inside brackets).

This is a third paragraph.

With the cursor being on the `S`.

Is this an exception to the exception? Or am i simply getting it all wrong?

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: