Search code examples
vim

vim Error detected while processing function <SNR>66_MRU_Select_File_Cmd


I use vim8. When I use vim, whether I open or save a file, there will be errors. To save a file, I must use: w!, Open the file must be q to close the error.

Error detected while processing function <SNR>66_MRU_Select_File_Cmd[21]..<SNR>66_MRU_Window_Edit_File[67]..BufRead Autocommands for "*"..function <SNR>25_Detect[17]..<SNR>25_BufInit[1]..<SNR>25_autoload[2]..script /root/.vim/bundle/vim-rails/autoload/rails.vim[169]..function <SNR>87_add_methods[2]..<SNR>87_function:

I tried to reinstall vim, but it didn't work

sudo apt remove vim
sudo apt install vim 

Also try to modify the .vimrc file and copy the .vimrc file of vim that is normally used on other servers, but it doesn't work

I also tried to add the content shown in the answer here to the top of the file, but it still failed https://github.com/powerline/powerline/issues/1925

if has('python3')
  silent! python3 1
endif

and i tried the solution here, but it still failed Error detected while processing function vundle#installer#new

 set shell=/bin/bash

Then I tried the solution here, but it still didn't work https://github.com/vim/vim/issues/3117

mv ~/.vimrc ~/.vimrc_back
mv ~/.vim ~/.vim_back
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
cp ~/.vim/bundle/Vundle.vim/test/minirc.vim ~/.vimrc

What should I do so that vim can be used normally and no error will be reported


Solution

  • When a script is sourced by Vim it is given a number, which can be used to make sense of a stack trace like yours (edited for legibility):

    Error detected while processing function <SNR>66_MRU_Select_File_Cmd[21]
    ..<SNR>66_MRU_Window_Edit_File[67]
    ..BufRead Autocommands for "*"
    ..function <SNR>25_Detect[17]
    ..<SNR>25_BufInit[1]
    ..<SNR>25_autoload[2]
    ..script /root/.vim/bundle/vim-rails/autoload/rails.vim[169]
    ..function <SNR>87_add_methods[2]
    ..<SNR>87_function:
    

    Before reinstalling Vim, a more constructive approach would be to figure out whether the problem occurs in Vim's own runtime files or in yours. You can use :help :scriptnames to put a filename to those numbers, so to speak.

    Without even seeing the output of that command, it doesn't take much effort to find out that at least some of your problems come from your runtime files:

    " one plugin
    <SNR>66_MRU_Select_File_Cmd[21]
    <SNR>66_MRU_Window_Edit_File[67]
    
    " another plugin
    ..script /root/.vim/bundle/vim-rails/autoload/rails.vim[169]
    ..function <SNR>87_add_methods[2]
    ..<SNR>87_function:
    

    Which means that you should look for the actual cause, not throw the towel and reinstall Vim or try random answers to random unrelated questions.

    One good starting point would be line 21 of function MRU_Select_File_Cmd() in script number 66, which should be a call to MRU_Window_Edit_File() in your outdated version. The stack trace then points to line 67 of that function, and so on.

    Hypotheses:

    • badly installed plugins,
    • incompatible Vim version,
    • incompatible plugins,
    • options incompatible with your plugins,
    • etc.

    Good luck.