Why doesn't the cursor go beyond the last character in Vim when in command mode?

1,601 views
Skip to first unread message

Gerardo Marset

unread,
Feb 24, 2011, 6:06:48 PM2/24/11
to v...@vim.org
I'm quite new at Vim and I love it already, but this question just won't
let me sleep.
Why is it that the cursor doesn't go beyond the last character when in
command mode?
I find it kind of wierd, and because of that I have to use either a or A
to append something to a line (instead of i).

Thanks in advance.

And by the way, both the faq
(http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl) and the tips
archive (http://www.vim.org/tip_index.php) seem to be broken...

Ben Schmidt

unread,
Feb 24, 2011, 7:52:19 PM2/24/11
to vim...@googlegroups.com, Gerardo Marset, v...@vim.org
On 25/02/11 10:06 AM, Gerardo Marset wrote:
> I'm quite new at Vim and I love it already, but this question just won't let me
> sleep.
> Why is it that the cursor doesn't go beyond the last character when in command mode?
> I find it kind of wierd, and because of that I have to use either a or A to append
> something to a line (instead of i).

Put this in your vimrc (I hope you have one and know a little about how it works!):

:set virtualedit=onemore

See

:help 'virtualedit'

Ben.

AK

unread,
Feb 24, 2011, 8:00:32 PM2/24/11
to vim...@googlegroups.com
On 02/24/2011 06:06 PM, Gerardo Marset wrote:
> I'm quite new at Vim and I love it already, but this question just won't
> let me sleep.
> Why is it that the cursor doesn't go beyond the last character when in
> command mode?
> I find it kind of wierd, and because of that I have to use either a or A
> to append something to a line (instead of i).

I don't find it weird personally, and I don't think 'a' is any harder to
use than i, and you can also use i and then move cursor one char to the
right, as well.

However, there is a 'virtualedit' option that allows you to move one
char past end of line:

:set virtualedit=onemore

see

:help 'virtualedit

-Rainyday

John Beckett

unread,
Feb 25, 2011, 1:35:38 AM2/25/11
to vim...@googlegroups.com
Gerardo Marset wrote:
> Why is it that the cursor doesn't go beyond the last
> character when in command mode?
> I find it kind of wierd, and because of that I have to use
> either a or A to append something to a line (instead of i).

There is also:
:set virtualedit=all
:help virtualedit

One advantage of using A to append to end of a line is that the
operation can be repeated on another line by pressing . (if you
happen to need the same text appended to more than one line).

> And by the way, both the faq
> (http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl) and
> the tips archive (http://www.vim.org/tip_index.php) seem to
> be broken...

The FAQ is now at:
http://vimhelp.appspot.com/vim_faq.txt.html

The tips are at:
http://vim.wikia.com

John

Erik Christiansen

unread,
Feb 25, 2011, 1:51:24 AM2/25/11
to vim...@googlegroups.com
On Thu, Feb 24, 2011 at 09:06:48PM -0200, Gerardo Marset wrote:
> I find it kind of wierd, and because of that I have to use either a or A
> to append something to a line (instead of i).

Just one thought, in addition to the others: A major benefit of using
'A' is that you can do it from anywhere in the line, without cranking
the cursor all the way there first. (OK, you can pause for a sip of
coffee while waiting for the cursor to run up there, for 'i' to work,
and that may be a counter-benefit. ;-)

And, as said, being able to '.' on other lines can be a big productivity
bonus.

Erik

--
The truly lazy person puts in the time & effort to learn how to do
things the easy way and reaps the laziness benefits for years
afterwards. - Craig Sanders, on luv-main ML.

Gerardo Marset

unread,
Feb 25, 2011, 9:24:30 AM2/25/11
to vim...@googlegroups.com

Nice.
Yes, I have a vimrc and I know how it works.

Well, after reading the replies and the help entry for virtualedit, I
think I'll leave it as it is after all.

Thank you and everyone else who helped. :)

Reply all
Reply to author
Forward
0 new messages