gVim error on startup: E121: Undefined variable: paste#paste_cmd - vim

In gvim 8.1.1401 on Debian 10.4 when I open a file from Thunar with Right-click -> Open With -> Open with "gVim"
I have been getting an error popup:
Error
Error detected while processing /usr/share/vim/vim81/menu.vim:
line 166:
E121: Undefined variable: paste#paste_cmd
[OK]
When I open the same file from the command line with gvim /path/to/file it doesn't happen.
I don't get it launching normal vim from the command line either.
I tried uninstalling and re-installing all of my vim packages, in case it was picking up incompatible files from an old version. This didn't help.

I googled for the error and found various clues:
https://bugs.debian.org/388488
https://bugs.debian.org/520360
https://groups.google.com/d/topic/vim_use/x4R_QF-MXnE/discussion
GVIM - undefined variable: paste#paste_cmd?
They pointed me in the right direction to find it, i.e. an invalid runtimepath in ~/.vimrc, but were not the exact same error and didn't detail the solution I discovered.
By editing my ~/.vimrc and trying different things I tracked down the cause.
Because I couldn't find the answer online I'm sharing it here.
If you have:
set runtimepath=
in ~/.vimrc AND if that line does not include /usr/share/vim/vim81
then you will get the error.
If you don't have a ~/.vimrc you won't get the error.
If you don't have a runtimepath= entry you won't get the error.
If ~/.vimrc has a runtimepath= entry and it includes /usr/share/vim/vim81 in the path, then you won't get the error.
If this is still an issue in future versions of vim after 8.1 which doesn't have the vim81 directory, then the numbers will need to be updated to point to a valid directory for that version e.g. vim82 (or later)
NB: If the runtimepath in ~/.vimrc is correct, but vim81/autoload/paste.vim does not exist you will also get the error.
If vim81/autoload/paste.vim does exist, but the paste_cmd is commented out/deleted/corrupted, you will get the error (and an instance of it from each entry in vim81/autoload/paste.vim and any other files which refer to paste_cmd)
I hope this saves people time and prevents frustration!

Related

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
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.

Vim isn't loading syntax

I had an unrelated problem with vim a while back, that I thought deleting all vim files would help. It did not, but now I have a new problem. Whenever I try to put syntax on, it says:
Error detected while processing /home/jonah/.vimrc:
line 16:
E484: Can't open file /usr/share/vim/syntax/syntax.vim
I've tried reinstalling fully, but it doesn't fix the issue.
You still have a broken Vim installation with missing runtime files. The file $VIMRUNTIME/syntax/syntax.vim needs to be there. You should never modify / remove system runtime files in /usr/share/vim yourself! Use your distribution's package manager (you didn't tell which Linux disto you're using) to completely reinstall Vim, and ensure that the file is there.

Vimball error, unrecognized character in path

I have a problem with installing SuperTab from vimball. I get an error:
E739: Cannot create directory: C:\Users\Pawe<b3>\vimfiles
I guess the problem is the directory name which is C:\Users\Paweł\vimfiles. Is there a way to solve it without changing directory name? Btw: I have set encoding=UTF-8 in my vimrc.
Edit:
The way I install it is so: download .vmb file, open it with vim (using context menu: 'edit with vim') and then I write :so %. And the error occurs.
Using :set verbose=20 I get http://pastebin.com/BLaeLzuU (those are things I found interesting).
And here's the wider story. I was trying to install plugins using vimballs, because I failed running plugins with pathogen (identical case as here: https://github.com/tpope/vim-pathogen/issues/110. In fact my output of :scritpnames is here: http://pastebin.com/YBTBvsvz). To tell you the truth I even tried to copy folder plugin form plugins git repo to my ~\vimfiles. With no success (they are not mentioned in scriptnames). And so I don't have any clue what is going on. Only that output from vimball tells me that it could be the path name. Other then that, I'm hopeless.
Btw: using Windows 8 if that's a deal breaker.
Eventually I have renamed the user name and user folder because the directory name was a problem for other aplications too. Here are the instructions: https://superuser.com/questions/495290/how-to-rename-user-folder-in-windows-8

How to set up syntastic for vim?

So I git cloned the repository to ~/.vim/bundle and had pathogen installed. I can be sure pathogen works fine since my other plugins in bundle are all working fine. After googling for a while, it seems that syntastic should work out of box for c code. I also checked that I have all the executables specified in syntastic/syntax_checkers/c/.
Here is a part of my .vimrc file:
" syntastic
let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1
When I open a *.c file and do :SyntasticCheck, nothing happens. There is no errors complaining command not found, so syntastic is loaded. However, even if the *.c file that's currently opened contains errors syntax error, syntastic is not showing anything.
It is the first time I use syntastic so I don't really know the correct way to invoke it.
I also tried :SyntasticCheck [c] and I get the following error message:
Error detected while processing function <SNR>_22_UpdateErrors..<SNR>22_CacheErrors:
line 16:
E121: Undefined variable: checkers
E15: Invalid expression: checkers
Can someone tell me what I did wrong and how to invoke syntastic?
Thanks!
Try adding this to your vimrc:
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1
(This is lifted straight from my vimrc, which has some other Syntastic settings if you'd like.)
I don't really understand the reason, but when I re-installed the YouCompleteMe plugin for vim with ./install.sh --clang-completer. Syntastic works like charm.
Installing clang and/or ctags packages fixed this for me
I did two things and then Syntastic started to behave as expected with JS files and ESlint. Can't tell which one did the trick:
1- In the project's directory ran eslint --init.
2- Started vim opening the file without the -S flag.
Before it failed silently, no errors and no diagnostics. This is how ESlint behaves when there is no configuration file.

fuzzyfinder: Error detected while processing function <SNR>19_onCommandPre

When typing an command, I get an error like this:
:w
Error detected while processing function <SNR>19_onCommandPre..fuf#mrucmd#onCommandPre..<SNR>25_updateInfo..fuf#updateMruList:
line 2:
E121: Undefined variable: word
line 5:
E121: Undefined variable: word
Is it a bug or just cause by my incorrect configuration?
I set let g:fuf_modesDisable=[] in my .vimrc.
And the vim version I use if vim 7.3, the fuzzyfinder version is fuzzyfinder 4.2.2
I had the same (or very similar) problem. I've filed issues against FuzzyFinder.
If you follow the link you will find the details of my investigation together with solution.
If nothing else work I believe that wiping out ~/.vim-fuf-data directory will do. But better to try what is described in the issue first (~/.vim-fuf-data/mrufile/items).
I encountered the same error. Deleting the FuzzyFinder data file fixed the issue for me. Of course I am starting from scratch now, but it works!
Delete the following:
~/.vimfuzzyfinder
Just doing a plugin install seemed to fix the issue for me

Resources