Syntastic installation issue: ^M file endings - vim

I'm trying to install Syntastic for Vim using Cygwin. After completing step 2.1 and the cloning part of step 2.2 in the installation guide of Syntastic, I find that now when I run vim I get the following errors:
Error detected while processing /home/rjw08/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim:
line 1:
E15: Invalid expression: exists("g:loaded_syntastic_notifier_autoloclist") || !exists("g:loaded_syntastic_plugin")^M
line 39:
E171: Missing :endif
Error detected while processing /home/rjw08/.vim/bundle/syntastic/plugin/syntastic/balloons.vim:
line 1:
E15: Invalid expression: exists("g:loaded_syntastic_notifier_balloons") || !exists("g:loaded_syntastic_plugin")^M
line 67:
E171: Missing :endif
Error detected while processing /home/rjw08/.vim/bundle/syntastic/plugin/syntastic/checker.vim:
line 1:
E15: Invalid expression: exists("g:loaded_syntastic_checker") || !exists("g:loaded_syntastic_plugin")^M
There were a few more errors, but they follow this basic format. From what I understand, file endings in the listed files are incorrect (i.e. ^M). However when I open these files in Vim, there does not seem to be any ^M endings to delete.
How do I fix this problem?

Load the file into vim, then :set fileformat=unix and :wq should fix it.
PS: you don't see the ^Ms because vim thinks it is a dos file (it probably says [dos] in the status bar after loading).

This command will transform every file to a unix file in the ~/.vim/bundle directory.
find ~/.vim/bundle -type f -follow -print|xargs dos2unix

Related

Errors while sourcing .vimrc

I am using bash terminal and in my .vimrc I have the following lines:
set number
"set tags+=/users/vinod/ctags_related/tags
imap 2s <SPACE><SPACE>
When I save and then try to source my .vimrc, I get the following errors:
bash: /users/vinod/.vimrc: line 2: unexpected EOF while looking for matching `"'
bash: /users/vinod/.vimrc: line 4: syntax error: unexpected end of file
The line number shown in the second error doesn't exist in my .vimrc
Why am I getting these errors? How can I fix them?
TIA
Vinod
If you are doing source ~/.vimrc from the terminal prompt, then you are getting errors you should expect. The .vimrc file contains vimscript, which only the vim program understands. Bash is giving you errors because it is not supposed to source that file. When you start vim, normally by just typing vim and hitting enter, vim will automatically source your .vimrc

error when trying to implement vim-plug in .vimrc

I am trying to install vim-plug and I followed your instructions in your tutorial. I have written in .vimrc like so:
call plug#begin('~/.vim/autoload')
call plug#end()
but I get the following errors:
-bash: /Users/user/.vimrc: line 18: syntax error near unexpected token `('
-bash: /Users/user/.vimrc: line 18: `call plug#begin('~/.vim/autoload')'
Do you know what I am doing wrong?
Note how the error messages you're receiving start with -bash:, which indicates these lines are being parsed by bash, not Vim.
Can you somehow explain how that is happening?
Are you by any chance sourcing this file from your shell? Are you referring to .vimrc from somewhere? How are you starting Vim exactly? Do you have some commands in your .vimrc around these lines that would cause them to be passed to a shell?
Figuring out how this is happening should make it easy for you to figure out how to fix it.

Added new scripts for vim functionality that is not working

I am in a Mac OS and I just added some scripts to get new functionality from my vim editor and when I go back into the vimrc file I continue to get this error:
vim ~/.vimrc
Error detected while processing /Users/danale/.vimrc:
line 12:
E117: Unknown function: pathogen#infect
E15: Invalid expression: pathogen#infect()
I have looked at similar posts here that are not very helpful. Ultimately, I would like to use nerdtree configuration so I can use VIM as my IDE.
If I hit enter anyway, I get this error:
Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree | endif
and it does not take me to a nerdtree type of view just an empty welcome to vim view.
You need to install pathogen.

updated mccvim, now cannot source $HOME/.vimrc

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 21 2017 01:21:26)
MacOS X (unix) version
Included patches: 1-1207
My .vimrc has
:nmap ,s :source ~/.vimrc I tried that right after installing the mccvim just now, and got these errors:
Error detected while processing /Users/jk/.vimrc:
line 18:
E15: Invalid expression: 0^M
line 20:
E15: Invalid expression: has("gui_running") && has("menu")^M
line 99:
E15: Invalid expression: 0^M
line 101:
E15: Invalid expression: has("gui_running") && has("menu")^M
line 203:
E15: Invalid expression: 0^M
line 205:
E15: Invalid expression: has("gui_running") && has("menu")^M
I don't find '0^M' in the .vimrc at all.
Everything was fine until the update; what happened?
Unix-like systems (including OSX) and Windows have different conventions on what "end of line" should look like. Unix uses LF (ASCII 0A, also represented as ^J); Windows uses CRLF (ASCII 0D0A, also represented as ^M^J.
Vim can use both kinds of files, depending on its fileformats (ffs) setting. set ffs=unix,dos will make Vim try to guess how the file is formatted, and sets the fileformat (ff) accordingly. However, if ffs is set to just unix, then Vim will not try to guess, ff gets set to unix; under this setting, if the file was saved for Windows (i.e. has CRLF line endings), LF will be interpreted as newline, and CR will be presented as ^M. Vimscript doesn't know what to do with ^M, and complains.
To convert your file to Unix format (the recommended action, since your file is foreign to the operating system you're using), run these commands:
:e ++ff=dos .vimrc
:setl ff=unix
:w

Unable to find ^M when reading file

I am using a linux OS and attempting to find the ^M characters in a .vim file, specifically jcommenter.vim. I would like to find and replace the ^M characters but am unable to do so. I have tried
%s/^V^M//g
and
%s/\r/\r/g
Unfortunately neither are able to find ^M. I have read that when vim reads a file, it will not include ^M, is this true? How can I find and get rid of ^M?
Edit:
This is a sample of the error I recieve:
line 21:
E492: Not an editor command: ^M
line 31:
E492: Not an editor command: ^M
This occurs everywhere there is a blank line.
EDIT:!!!
I have found a clue!
/usr/share/vim/macros/jcommenter.vim"[converted][dos]
dos?????? How do I destroy [converted][dos]?
To convert your file from "dos" format to "unix" format, load the file in vim and do:
:set ff=unix
:w
:q
The ff is short for fileformat.
You can do like
$ dos2unix plugin/jcommenter.vim
Use fromdos file (in command line, not in vim). This usually gets rid of odd control characters.
If you don't have it you can get it from the standard repos

Resources