VIM broken

For two days now VIM is broken in a number of ways:

  1. search no longer has a history. After the / command the up and down arrow key used to allow you to scroll through previous searches - this no longer works.
  2. EX commands no longer have a history. After the : command the up and down arrow key used to allow you to scroll through previous EX commands - this no longer works.
  3. The c and C commands have changed. Previously the text to be changed would contract and new text entered, making it look as what you see is what you get.

I have no problem with syntax highlighting reported in a previous post since I have ‘syntax on’ in my .exrc file set up a long time ago.
I am a very long term user of VI since 1980 with UNIX and SuSE Linux since 1994. Have used VIM when it became available, which has been so much improved. It is a pity to see changes causing these minor inconveniences.
PS: I have noticed other inconsistencies in VIM and will report them as I can pin them down.

I have noticed the following extra change in Vim since 2 days ago:

  1. When opening a previously edited file the cursor would be set at the place where the file was previously closed. This no longer happens - The cursor always starts at the beginning of the file.
  2. When the cursor sits on one of the bracketing character ( { ] } ), it would previously highlight the matching bracket character with a blue background. This no longer happens. Moving to the matching bracket with % is Ok.

Take a look at the other thread on this topic:

https://forums.opensuse.org/showthread.php/547648-Vim-Syntax-Highlighting-Broken-after-Upgrade

Just checked one of my recently updated LEAP 15.2,

No problems with history for both “search text string” and ex histories.

Recommend you try “force re-installing” vim which will also over-write your current vim configuration file. Save the file before re-installing and copy back in place afterwards to save your custom settings.

zypper in -f vim

TSU

Thank you for the quick reply. I backed up my .exrc file. I did not have a .vimrc file.

“zypper in -f vim” gave the following message:

Checking for file conflicts: ......................................................................................[done]
(1/1) Installing: vim-8.0.1568-lp152.8.3.1.x86_64 .................................................................[done]
Additional rpm output:
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/vim-nox11 because link group vim is broken

The re-install made no difference. No histories of search strings and ex commands. Also still starts with the cursor at the beginning of the first line not where it left off at the last edit.

I also noticed that the ‘undo’ facility with ‘u’ is not working correctly. Every time you press ‘u’ it toggles between the last change and then back to where you were. No history!!
I already noticed this before with other inconsistencies in editing. It is most annoying - VIM seems to be dying.

I have not rebooted - is that necessary?

Rebooting should not be necessary.

First, let’s verify your alternatives is set correctly. Run the following command and see if your result is the same

# update-alternatives --config vim
There is only one alternative in link group vim (providing /usr/bin/vim): /usr/bin/vim-nox11
Nothing to configure

Assuming you see the above,
I recommend you run “force” re-install vim but with the default configuration files.
I assume your history should be restored and if that is the case then you can look at what is inside your own custom file… Something may have changed that needs your attention (maybe diff your config files?).

TSU

What difference did you expect? Did you try to actually read the other thread that was pointed to you? The latest update removed /etc/vimrc which contained default configuration. You may reinstall it until you are blue in the face - it won’t bring removed file back. Either create your personal vimrc with whatever configuration you need or downgrade vim to previous version, save /etc/vimrc, install update (which will remove /etc/vimrc again) and then copy saved /etc/vimrc back. It will not belong to any package now and so will not be removed on next updates.

And as I already told OP in another thread - if you are concerned by this change, you should open bug report so it can be fixed.

update-alternatives --config vim
I get exactly the same output for

update-alternatives --config vim

I apologise, but what exactly do you mean by “force” re-install vim with the default configuration files ? Which configuration files ?

/etc/vimrc is gone as mentioned by “arvidjaar”. Since I do not have problems with syntax highlighting I did not register that /etc/vimrc was important in my case also - is it ?

Since I have been using VI for so long I still use a ,exrc file with a lot of my own macros - I have diffed a backup and it has not changed. My macros still work.

" $Id: .exrc,v 1.15 2008/07/07 19:13:41 root Exp root $
" .exrc for vi
" Author: Klaus Franken, kfr@suse.de

" added Super-Stutter-Sequences and useful function key mappings
" Author: John E. Wulff, wulff.johne@gmail.de
" modified for US-ASCII keyboards

" The following settings are useful for programming:

syntax enable

" activate the mouse for 'xterm'
set mouse=a

" keep at least 2 lines above or below the cursor when scrolling
set so=2

" searches are case sensitive
set noignorecase

" show cursor line and column in the status line
set ruler
" show INSERT/REPLACE mode in status line
set showmode
 ^
map  $ matching parentheses, and braces
set showmatch
" Insert Delete PageUp PageDown on xterm and linux
map  il to start with !
map  xell=bash
map  
map  ompatible works strangely with :g//s///g
" - alternates last g every line
" F1 - F10 in insert mode for xterm

map! <F1> ht search
map! <F2> ch
map! <F3> ~ wulff
A p! <F4> :r !timestamp
map! <F5> [numbering
map! <F6> ]enumber
map! <F7> {
map! <F8> }
map! <F9> \ for programming
map! <F10> |th=4  
set tabstop=8
" shift F1 - F10 in insert mode for xterm
set nowrap
map! <S-F1> 
map! <S-F2> n linux
map! <S-F3> ~
map! <S-F4> @
map! <S-F5> ]
map! <S-F6> <>xterm
map! <S-F7> {}
map! <S-F8> ()
map! <S-F9> ""
map! <S-F10> ''

" F1 - F10 in command mode for xterm

" move to next error entry
map <F1> :cn
" write to the temporary buffer for transfer between windows
map <F2> :w! /tmp/vim_buffer
" next file in argument list
map <F3> :n
" change in line /* C comments */ to // C++ comments
map <F4> :g/\/\*\(.*^   ]\)    ]*\*\/$/s//\/\/\1/
map <F5> :e 
map <F6> :e #
map <F7> {
map <F8> }
map <F9> :g//s//
cwp <F10> 0/\/\/\/

" shift F1 - F10 in command mode for xterm

" move to previous error entry
map <S-F1> :cN
" read from the temporary buffer for transfer between windows
map <S-F2> :r /tmp/vim_buffer
" previous file in argument list
map <S-F3> :N
" change // C++ comments^M to in line /* C comments */
map <S-F4> :g/\/\/\(.*\)$/s//\/\*\1 \*\//
map <S-F5> :e! 
map <S-F6> :e! #
map <S-F7> {
map <S-F8> }
map <S-F9> :g//s//
map <S-F10> {!}fmt -w72

" special command mappings of spare letters

" mark position and transfer to tag at cursor
map - mt
" return to previous file
map _ :e#
" quits like less - unmap when recording
map q :q

" The 'Super-Stutter-Sequences'

})i iii if ) {
///heee } else {
///^f)i } else if ) {
///^f)i } elsif ) {
})i www while ) {
} while );f)i
})i fff for ) {
})i ffe foreach ) {
}%F)i;t:switch ) {
break;k$iase:
:ab ppp printf(
");\i
} /* main */k^hchar **argv)
eab rrr ///zzz){///} /* zzz */>>?zzz
:ab kkk /* */hi
:ab KKK /** */hi
:ab lll /* **///kA
:ab LLL /** **///kA
:ab hhh ////**1a****** ****1a******/kA
:ab HHH ////\2i*********\/2i******kA
:ab PPP ///2i#########2i######kA
a******kA;*;*;**
:ab DDD i#define
dwi FFF ///PPOi#ifdef VVVoi#elseoi#endifVVV
:ab III i#include 
:ab CCC class {private:///public:///};>>kk>>kk$hi
:ab SSS struct {///};>>k$hi
:ab UUU union {///};>>k$hi
:ab AAA /$$////k2<<oDi

You may have to inspect your ‘,exrc’ file against the following files in “/usr/share/vim/current/”:vimrc_example.vim
defaults.vim

  • whatever else that gets pulled in when Vim or ex starts …

BTW, why “,exrc”?

  • The current Vim help doesn’t list that possibility …

That was a typo - it should be .exrc - since way back when vi evolved out of the ex editor the config file was always ~/.exrc
Thanks for the tips. I will check out the files you mentioned.

The procedure I described attempted to suggest that you try to run vim as it is installed by default nowadays…
Perhaps I should have added removing your .exrc file when doing this.
The objective is to test whether a default installation works properly on your system.

If you can verify a default installation works properly, you can then inspect the difference between default and your configuration.

There may be something that has changed in how your .exrc is used by vim… As you already know (but others reading this thread may not) that ex is a special mode running vim, and although you’d probably expect that ex mode configurations should be separate from vim mode configurations, the two are so closely related that there may be some “bleed over” where one might affect the other.

In fact, I posted a gist recently that installs prerequisites for ocsinventory on LEAP 15.2, and used ex in line 35 to insert a setting in the middle of the file text

TSU

I have finally fixed VIM by obtaining a version from my old laptop with OpenSUSE Leap 42.3
I was not able to locate a version that worked online or in the /snap backups.

The removal of vimrc from /etc really caused a lot of grief and should be fixed. If you really have problems with SPEC files, the following lines should be removed:

" Skeleton for spec files
autocmd BufNewFile      *.spec  call SKEL_spec()

also possibly the whole SKEL_spec function.

As a final note the worst part of not having a vimrc file was that the move cursor arrow keys caused mayhem in insert mode. The ESC of those arrow keys stopped insert mode and the rest of the ESC sequence was used as a VI command.

All search and ex histories now work as well as the other bugs reported by me.

Please help me to open a bug report so that this can be fixed properly. I do not know how to do that.

I notice two bug reports already, that are related to this. They are:

Bug 1179307 – Latest vim update breaks colored highlighting
and
Bug 1179384 – vim - insert mode - backspace not working on existing content

You should be able to comment on those bug reports. The same login/password that you use for the forums should also work for the bugzilla.

To start a new bug report, I normally use openSUSE:Submitting bug reports
but in this case, it makes more sense to use the existing bug reports.

You can recover a copy of the factory ‘/etc/vimrc’ by retrieving the version 8.0.1568-lp152.7.1 from the RPM in the OSS repository – <http://download.opensuse.org/distribution/leap/15.2/repo/oss/x86_64/&gt; – download “vim-8.0.1568-lp152.7.1.x86_64.rpm” – «do not install it!!», open it with “Ark” and, extract ‘/etc/vimrc’ …

The procedure I described to force install vim should have worked…

I inspected a couple of couple of my 15.2 machines… one a virtual machine that has been in a “deep freeze” for several months and a machine I’ve been updating regularly and found /etc/vimrc on both machines.
I then inspected the package vim on my recently updated machine

# rpm -ql vim | grep /etc/
/etc/alternatives/vim
/etc/vimrc

Bottom line, at least in my experience if /etc/vimrc was removed at any time by a package install or update, it hasn’t been seen by me… I can’t find any evidence of it.
And, a default install should re-install vim with a working /etc/vimrc. And, a missing /etc/vimrc isn’t necessarily a show stopper but could be an inconvenience with unknown consequences… There have been many postings and discussions about that over the years but restoring either a /etc/vimrc or ~/vimrc usually has fixed the problem.

BTW - Although not particularly important, if anyone has more information about whenever /etc/vmrc might have been removed, I’d appreciate any posting for future reference although from what I can see I don’t expect to see the problem again for now.

TSU


 > cat /etc/os-release 
NAME="openSUSE Leap"
VERSION="15.2"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.2"
PRETTY_NAME="openSUSE Leap 15.2"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.2"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
 > 
 > rpm --query --list vim | grep -i '/etc'
/etc/alternatives/vi
/etc/alternatives/vim
 > 
 > rpm --query --info vim
Name        : vim
Version     : 8.0.1568
Release     : lp152.8.3.1
Architecture: x86_64
Install Date: Mo 30 Nov 2020 20:09:00 CET
Group       : Productivity/Text/Editors
Size        : 3193171
License     : Vim
Signature   : RSA/SHA256, Di 24 Nov 2020 00:03:24 CET, Key ID b88b2fd43dbdc284
Source RPM  : vim-8.0.1568-lp152.8.3.1.src.rpm
Build Date  : Di 24 Nov 2020 00:02:20 CET
Build Host  : cloud133
Relocations : (not relocatable)
Packager    : http://bugs.opensuse.org
Vendor      : openSUSE
URL         : http://www.vim.org/
Summary     : Vi IMproved
Description :
Vim (Vi IMproved) is an almost compatible version of the UNIX editor
vi. Almost every possible command can be performed using only ASCII
characters. Only the 'Q' command is missing (you do not need it). Many
new features have been added: multilevel undo, command line history,
file name completion, block operations, and editing of binary data.
Distribution: openSUSE Leap 15.2
 > 

I guess I had to look harder.
Found a machine of mine which is also missing /etc/vimrc in the package contents although it had an /etc/vimrc.

Inspected the package, I see no indication that the missing /etc/vimrc was intentional (although could be, who knows).

I did find though in the package the following file with express instructions it should be installed as /etc/vimrc in its comments

/usr/share/doc/packages/vim/suse.vimrc

On this machine of mine which I think was newly installed approx Feb 2020, it has a /etc/vimrc although its current installed vim package is missing the file and was updated as recently as yesterday.** I just ran an update and it looks like /etc/vimrc was removed**… Interestingly, when I look at the log of what was in the update I just ran, there is nothing in it related even closely to vim… The following is what was updated

The following 23 packages are going to be upgraded:  libgstadaptivedemux-1_0-0 libgstbadaudio-1_0-0 libgstbasecamerabinsrc-1_0-0 libgstcodecparsers-1_0-0
  libgstmpegts-1_0-0 libgstphotography-1_0-0 libgsturidownloader-1_0-0 libgstwayland-1_0-0 libQt5Core5
  libQt5DBus5 libQt5Gui5 libQt5Network5 libQt5OpenGL5 libQt5PrintSupport5 libqt5-qtbase-platformtheme-gtk3
  libQt5Sql5 libQt5Sql5-sqlite libQt5Test5 libQt5Widgets5 libQt5Xml5 python3-pip youtube-dl
  youtube-dl-bash-completion

I then created /etc/vimrc as instructed in the file

cp /usr/share/doc/packages/vim/suse.vimrc /etc/vimrc 

After a reboot, the newly created /etc/vimrc is still there.
I guess its status can be re-checked after another update when it comes.

TSU

Hi
Suggest a perusal of Change Logs would help?

Tumbleweed;

-------------------------------------------------------------------
Tue Jun 30 15:14:06 UTC 2020 - Ludwig Nussel <lnussel@suse.de>

- stop owning /etc/vimrc so the old, distro provided config actually
  gets removed. Leaving it around leads to a duplicated autocmd for
  *.spec, leading to spec file template inserted twice.

Leap 15.2 update…
https://build.opensuse.org/package/view_file/openSUSE:Leap:15.2:Update/patchinfo.15098/_patchinfo?expand=1

Thx,
That link led to some further investigation…

Apparently for at least 8 years now VIM has been distributed in a variety of sizes…
The following is a key to the features that are published in the VIM documentation

http://vimdoc.sourceforge.net/htmldoc/various.html#+feature-list

The first column shows the smallest version in which they are included:T   tiny
S   small
N   normal
B   big 
H   huge

This may be the reason why I’ve found VIM in Debian/Ubuntu to be so primitive… Apparently since 2014, their VIM has been “tiny.”
Of course, if the default openSUSE VIM is now “small,” the missing history described by @OP is a likely intentional consequence of the change.
I wonder how many other issues will pop up over time, and so far I’m seeing no certain guide how to restore or change the VIM version, if it can be done by simply installing an /etc/vimrc. I’ve been reading that the way to restore features requires re-compiling.

Frankly, I don’t understand the text Malcolm highlighted about *.spec files being read twice…
Based on a small search, as expected I didn’t see anything that made a .spec file essential during runtime, it’s used during build and as a text editor if you want to edit a spec file belonging to something else.
So, I just don’t understand the reasoning for removing /etc/vimrc (BTW - this seems to be something unique to openSUSE, the system-wide vimrc file is normally located in the /usr/ tree)

TSU

Hi
Um, never tried the template?


vim tsu2_has_not_tried_this.spec