vim Error detected while processing function <SNR>66_MRU_Select_File_Cmd - vim

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.

Related

Vim Latex Suite can't find latex command using Pathogen

Background
I was having dual boot issues with Windows 10 and Ubuntu 17.10, which eventually resulted in a boot loop and since I need Ubuntu 16.04.3 for an Operating Systems class I decided to load up an ISO into one of my USBs with Rufus, reformat my Windows partitions from GPT to NTFS to get around some nasty bootmg/efi issues and here we are, good as new, except for one thing...
Problem
The only thing I haven't been able to successfully reinstall has been Latex Suite for Vim. Installation last time had been an easy extraction into .vim, but after some deliberation I elected to use Pathogen.
I've installed Pathogen using
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
Which works for color schemes, etc., and every other aspect of latex-suite save for compiling, generating this every time I try to compile (using \ll):
/bin/bash: latex: command not found
I installed texlive which does then allow me to compile using vim, but I'd prefer not to use this solution if I don't have to (in fact I've already removed it, its more of a plan b for now given it's obstructive and non-intuitive compilation errors). I looked at the other questions asking how to install Latex Suite through pathogen and didn't see anything else similar to what I'm working on; below is self-explanatory in regards to installation structure.
~/.vim/bundle$ ls
vim-archery vim-latex-1.10.0
Obvious running pdflatex and latex can't be found because they are not in my $PATH but I was under the impression that with a good, recommended package manager like Pathogen I wouldn't need to which is what originally raised the red flag for me as its whole job is to modify the runtime path. I thought maybe trying sudo vim text.tex might work in case there hadn't been adequate permissions for Pathogen to modify runtime path but no dice.
.vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
colorscheme archery
let g:tex_flavor='latex'
set sw=2

How to recover or reinstall .vim_runtime directory and contents

I downloaded this vim config but decided later I wanted to work using vanilla vim (because i'm still not used to it).
So I followed the instructions at the bottom of the README:
How to uninstall
Just do following:
Remove ~/.vim_runtime
Remove any lines that reference .vim_runtime in
your ~/.vimrc
I deleted the hidden vim_runtime directory located in :home/user/ on Ubuntu 16.04, using
rm -rf ~/.vim_runtime/
then realized this was a mistake. I now can't open vim without getting:
Error detected while processing /home/user/.vimrc:
line 3:
E484: Cannot open file /home/user/.vim_runtime/vimrcs/basic.vim
line 4:
E484: Cannot open file /home/user/.vim_runtime/vimrcs/filetypes.vim
line 5:
E484: Cannot open file /home/user/.vim_runtime/vimrcs/plugins_config.vim
line 6:
E484: Cannot open file /home/user/.vim_runtime/vimrcs/extended.vim
Press ENTER or type command to continue
I don't know what to do from here, It would be great if I could just purge it all and have vim as it was when you first install the OS, I've tried:
sudo apt-get purge vim && sudo apt-get install vim
but still get the same error detection when opening vim after the command has completed.
If you had no personal configuration other than that Vim distribution, just rm /home/user/.vimrc and start anew. You can also remove /home/user/.vim/ if it exists. That gives you a clean slate. There's no need to reinstall Vim; that distribution presumably was just user configuration (i.e. you didn't need sudo to install it), whereas Vim is installed system-wide (via apt). If there's something inside .vimrc that you want to save (and you have no other editor installed), you can launch Vim with vim -N -u NONE.
soapbox
Vim "distributions" like spf-13 and Janus lure you with a quick install and out-of-the-box settings, but you pay the price with increased complexity (you need to understand both Vim's runtime loading scheme and the arbitrary conventions of the distribution) and inflexibility (the distribution may make some things easier, but other things very difficult). Vim is incredibly customizable, using someone else's customization makes no sense.
new config
I would base your personal configuration on the example that ships with Vim. You can install it like this:
$ vim
:edit $VIMRUNTIME/vimrc_example
:saveas $MYVIMRC
:quit
Also see :help defaults.vim.

Cannot load CoqIDE plugin for vim

I'm trying to use the CoqIDE for vim plugin I found on this page.
I put the coq_IDE.vim file in ~/.vim/ftplugin folder. My current .vimrc file is:
set showcmd
set number
imap hl <Esc>
filetype plugin on
But when I start vim CoqIDE doesn't load automatically (I see no change whatsoever compared to normal vim, so I don't think it did). And when I try to load it manually by the command :source coq_IDE.vim, I get the following error message:
E484: Can't open file coq_IDE.vim
What could be the source of this error?
Here are some additional information that might be relevant:
1) I am running Ubuntu 14.04.
2) I checked that :version in vim shows +perl.
2) I am running vim from terminal, not gvim.
3) I tried removing and reinstalling different versions of vim (vim, vim-gtk, vim-gnome)
4) The CoqIDE installation guide says that coqtop.opt should be accessible via the PATH variable. Since I'm not even sure what this means, this might be the problem here, but that seems unlikely. From what I understand vim is getting errors when trying to read coq_IDE.vim, so it's not even getting to the part where it's looking for coqtop.opt.
5) I have CoqIDE installed from Ubuntu Software Center.
6) With :echo &runtimepath I get: ~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
The instructions are bad.
Put the file in ~/.vim/plugin not ~/.vim/ftplugin
The file layout should look exactly like the file layout found in this mirror for the plugin. https://github.com/vim-scripts/CoqIDE. (Maybe take a look at pathogen or vundle,).
The reason the :source coq_IDE.vim fails is vim is looking for the file coq_IDE.vim in the current directory and it isn't there. Use the full path to file if you are going to source it manually. (You shouldn't need to though.)

How Do I get a syntax check to work in/with vim?

This question has been asked, in one form or another, a dozen times here, and it blows my mind how not a single one actually addresses how to configure syntastic or jslint such that it actually does what it is supposed to do (its README file is completely useless)
see here
Can anyone provide some step by step instructions, or a link to such instructions. I tried to install jslint and spidermonkey, and I got nowhere.
I managed to get the syntax check to work (thanks to romainl). A few things I learned along the way that may help anyone with a similar problem
To build Javascript Lint look for the README file nested in jsl-x.x.x/src/README.html
The build instructions are gmake -f Makefile.ref but gmake is the same thing as make so issue the command sudo ln -s /usr/bin/make /usr/bin/gmake
jsl will now be found in jsl-0.3.0/src/Linux_All_DBG.OBJ/jsl. To make it generally accessible do something like: ln -s /whatever/jsl-0.3.0/src/Linux_All_DBG.OBJ /home/ForestGump/bin/jsl. More information here
To check that jsl actually works find a test file ( here) then issue the command jsl -process test.js. It should list all the errors.
To customize your command line, add this to your vimrc file set statusline=%{SyntasticStatuslineFlag()}
What did you do? What works and what doesn't? Do you get error messages?
Here is what I did:
Downloaded the jsl sources from the JavaScript Lint site.
Built jsl and moved it somewhere in my $PATH.
Checked if it worked by running it against a random .js file
Downloaded and installed Syntastic as a Pathogen bundle.
Typed :helptags /path/to/syntastic/doc because for some reason Pathogen's automatic help tags generation doesn't work for me.
Read Syntastic's documentation: :help syntastic.
Steps 1 to 5 didn't take more than 3 or 4 minutes, maybe less.
Step 6 is obligatory, whatever new tool you try. RTFM.
I didn't have to configure anything beside these 3 lines in my .vimrc (and I believe the third is redundant):
let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1
and customizing my statusline a bit with:
%{SyntasticStatuslineFlag()}
EDIT
Here is my statusline:
set statusline=%<\ %n:%f\ %m%r%y%{SyntasticStatuslineFlag()}%=line:\ %l\ of\ %L,\ col:\ %c%V,\ win:\ %{WindowNumber()}\
Don't copy it verbatim or you'll get some errors due to the function call at the end. There is a paragraph about that in syntastic's help.
END EDIT
After all that, 10 or 12 minutes if you count reading the documentation, I have a very helpful location list and signs poping up each time I save a .js file with syntax errors.
Setup vundle according to its README.
Put this into your .vimrc:
Bundle 'scrooloose/syntastic'
Then enter this command in vim:
:BundleInstall
That's it.
EDIT: Vundle has changed its syntax since I originally wrote this. Nowadays, you use
Plugin 'scrooloose/syntastic'
and then enter
:PluginInstall

vim and latex-box

I installed the vim plugin latex-box but I am having trouble getting it to compile my Latex file. The docs say it uses latexmk to do the compiling, and I have that installed and it works when called by itself.
But when I use the plugin's \ll command to compile I get an error that says 'cannot run latexmk in background without a VIM server'. I cannot find an explanation of why this error would occur in the plugin documentation.
EDIT:
I found a solution to this issue, but ran into others.
To fix this, you need to install the full version of vim (which is different depending on your OS) which will include things like server support. I suggest doing this even if you don't use this plugin because it will fix not been able to copy/paste from/to vim. In (K)ubuntu, install the package vim-gtk.
Start vim like this vim --servername SOMETHING file.tex
After doing this, the servername error went away and the compilation went through but the output from latexmk shows up on top of the file I'm editing. It doesn't overwrite it, it's just displayed on top of the text. When I move the cursor and vim highlights a word or bracket, that appears back on the screen. The only quick way I found to get rid of the compiler output is to scroll the file up and back down, that makes the text appear again.
You can ask vim to redraw the screen like this:
:redraw!
Append that command after running your latex command.

Resources