You are not logged in.

#1 2012-05-18 15:04:47

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

[Solved] Vim: Can only undo most recent change

Howdy-ha, folks.  So I've been (very) gradually making the transition from Geany to Vim over several months, mostly without issue.  However, I've been reluctant to use Vim for anything other than quick, simple operations for one reason: The "u" key will only undo the most recent change, as though there aren't any other changes in the history.  Hitting "u" a second time reverses the "undo" command, so that repeatedly hitting it will just remove and add the same small change over and over again.  No matter how much time I spend looking into this it seems I'm the only person who's ever had this problem, and it occurs regardless of whether /etc/vimrc and ~/.vimrc exist.  As a result, I can't do any complex editing for fear of botching something and needing to spend hours backtracing my mistakes.  Any help on this is appreciated.

Last edited by ANOKNUSA (2012-05-18 15:22:06)

Offline

#2 2012-05-18 15:08:48

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [Solved] Vim: Can only undo most recent change

First thing, are you sure you are in vim-mode and not in vi-mode?

set nocompatible

ᶘ ᵒᴥᵒᶅ

Offline

#3 2012-05-18 15:13:37

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: [Solved] Vim: Can only undo most recent change

Wow, quick on the draw, litemotiv.  No, I was not sure if I was in compatability mode.  Now I am sure, and that seems to be exactly what I needed.  But how is it that I could be in that mode for so long?  There's nothing in my .vimrc about it and, like I said, the problem was there with or without a config file.  Are options set in-session persistent?

Offline

#4 2012-05-18 15:17:19

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [Solved] Vim: Can only undo most recent change

I believe the default mode in which vim operates is still vi-compatible, so you have to explicitly add "set nocompatible" to your .vimrc...


ᶘ ᵒᴥᵒᶅ

Offline

#5 2012-05-18 15:21:40

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: [Solved] Vim: Can only undo most recent change

Ah. I never saw any mention of than on the Vim Tips wiki at all.  Good to know, though, and thank you.

Offline

#6 2012-05-18 15:24:34

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] Vim: Can only undo most recent change

the problem was there with or without a config file

That's odd.  When I run vim with no vimrc I have a deep undo history.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#7 2012-05-18 15:28:40

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [Solved] Vim: Can only undo most recent change

alphaniner wrote:

That's odd.  When I run vim with no vimrc I have a deep undo history.

That's probably because you have a /usr/share/vim/vimfiles/archlinux.vim file? smile


ᶘ ᵒᴥᵒᶅ

Offline

#8 2012-05-18 15:29:08

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] Vim: Can only undo most recent change

It should be default on Arch as /etc/vimrc refers to /usr/share/vim/vimfiles/archlinux.vim which contains the relevant setting.
See both files for details.

EDIT: cross post. wink

Last edited by skanky (2012-05-18 15:29:29)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#9 2012-05-18 15:34:53

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] Vim: Can only undo most recent change

litemotiv wrote:

That's probably because you have a /usr/share/vim/vimfiles/archlinux.vim file? smile

But doesn't that apply to OP too? hmm


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#10 2012-05-18 15:38:56

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] Vim: Can only undo most recent change

It should do. There's a comment in /etc/vimrc recommending against changing, so it's worth looking into. There are other settings there that could affect some behaviour, apparently.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#11 2012-05-18 15:57:34

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: [Solved] Vim: Can only undo most recent change

skanky wrote:

It should do. There's a comment in /etc/vimrc recommending against changing, so it's worth looking into. There are other settings there that could affect some behaviour, apparently.

That would likely be the issue: I overwrote the default with my own config file, without including runtime! archlinux.vim in my own config.  As far as I can tell, things are working as both user and root.  I suppose I should have paid more attention, but then again, there's no mention in the Arch wiki entry about not altering/deleting any of those files:

Arch Wiki Vim Entry wrote:

Vim's personal configuration file is located in the home directory: ~/.vimrc. Advanced users tend to keep a well-tailored ~/.vimrc. The global configuration file is located at /etc/vimrc. The fall-back $VIM variable is defined as /usr/share/vim/. For example, to create a global colorscheme the *.vim colorscheme file should be stored in /usr/share/vim/vimfiles/.

Currently, the vim global configuration in Arch Linux is very basic and differs from many other distributions' default vim configuration file. To get some commonly expected behaviors (like syntax highlighting, return to the line of the last edit...), consider using vim's example configuration file:

cp /etc/vimrc /etc/vimrc.bak
cp /usr/share/vim/vim73/vimrc_example.vim /etc/vimrc

It seems the comment in /usr/share/vim/vimfiles/archlinux.vim is all new users have to go on, and it's not usually the first place anyone looks.

Offline

Board footer

Powered by FluxBB