Saturday, May 22, 2010

Re: backspaces leaving Insert mode

On 05/22/2010 10:23 PM, James Cole wrote:
> Hi,
>
> On May 21, 5:48 pm, "John Beckett" <johnb.beck...@gmail.com> wrote:
>> NickC wrote:
>>> I've put up with this for years.  Whenever I leave Insert
>>> mode by typing the Esc key, the cursor backtracks one char.
>>> I almost always have to right-arrow, so I would like to
>>> change the behaviour so that the cursor stays where it is.
> [...]
>>
>> This is "by design" and won't be fixed. Sometimes people suggest
>> getting into the habit of pressing a (append) instead of i
>> (insert). Pressing Esc then gives no surprise.
>
> I also find this behavior a pain.  It causes me to extra work - more
> than just having to press 'a' instead of 'i'.
>
> For example, when I'm using Vim to draft prose, I'll often use
> indentation to organise the structure of the text.  So different
> paragraphs are at different levels of indentation.  And then I might
> take a paragraph I've written and break it into a number of double-
> spaced lines so I can more easily see the paragaph's
> internal structure.
>
> So if the above paragraph was indented like this
>
>     For example, when I'm using Vim to draft prose, I'll often use
>     indentation to organise the structure of the text.  So different
>     paragraphs are at different levels of indentation.  And then I
>     might take a paragraph I've written and break it into a
>     number of double-spaced lines so I can more easily see the
>     paragraph's internal structure.
>
> So I might break up like this:
>
>     For example, when I'm using Vim to draft prose,
>
>     I'll often use indentation to organise the structure of the
> text.
>
>     So different paragraphs are at different levels of indentation.
>
>     And then I might take a paragraph I've written and
>
>     break it into a number of double-spaced lines so I can
>
>     more easily see the paragraph's internal structure.
>
> Exactly where I break things up depends on the structure of the
> sentence, so I have to break it up manually.  Often I'll insert line
> breaks after commas or at the ends of sentences. So in the latter case
> I'd use ')' to jump to the next sentence, press 'i' then insert two
> carriage-returns, then press <ESC>.
>
> Say then the next break I want to put in is at the end of the sentence
> I've just moved to the start of its own line.  If <ESC> left the
> cursor where it was, the cursor would be at the start of the sentence
> and I could just press ')' to go to the ned.  But since <ESC> moves
> the cursor back one, I have to press ')' once to get to the start of
> the sentence I was just at, and then again to move to the next
> sentence (or I could of course type '2)' but either way it's extra
> work).
>
> The problem I'm describing tends to occur when you insert some
> characters before some pre-existing text and then want to move
> forwards in some chunk - such in the aforementioned case of using ')'
> but also with things like 'w'.
>
> Hopefully I've convinced you that the behavior of <ESC> moving the
> cursor back one position can create needless extra work.  I can't see
> any benefit to making <ESC> move the cursor back one like it does (not
> saying there isn't, but it's not apparent to me) so I'm wondering why
> it does that "by design", as mentioned above?
>
> At least it would be nice if Vim had an option for controlling how
> <ESC> effected the cursor position.  i.e. if you could do something
> like
>
>     :set noEscMovesCursor
>
> Regards,
> James.
>


When in insert mode, cursor is between two chars. When in command mode,
cursor is on top of a char, to make it possible to perform char
operations. When you press escape, cursor either has to move back one
char or forward one char. It can't stay in the place because it's in the
middle and that makes no sense in command mode. If you were at the end
of line, obviously cursor would not be able to move ahead one char which
means behaviour would be inconsistent.

That's the reason in the nutshell. I should not that current behaviour
works just fine for me and if it does not for you, you can always map
esc in ins. mode to do esc and then move forward. -ak

No comments:

Post a Comment