error when trying to implement vim-plug in .vimrc - linux

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.

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

Why is properly commented line in vimrc giving error for Missing quote?

I've been trying to add comments to my vimrc file and for some reason it is not allowing me to comment after the execute pathogen line.
4: execute pathogen#infect() "Enable Pathogen
5:
6: syntax on "*Syntax color highlighting*
With vimrc like this, saving and exiting and reentering vim, it gives me an error 'Line 4: Missing quote: "Enable pathogen'
I have syntax highlighting on, and all other comments I make show up as comments, but anything after () on that line doesn't. I don't know if it's something simple I'm missing or if anyone else has seen this, but it seems strange that it's just this one line giving me problems.
I am running Mac OS X 10.13.6 and Vim 8.2.600
Please, read :h :comment carefully
It is not possible to add a comment to a shell command ":!cmd" or to the
":map" command and a few others (mainly commands that expect expressions)
that see the '"' as part of their argument:
...
execute
...
syntax
Also note that if the command does not take "bar" as part of argument (see :h :bar), you still can do
execute pathogen#infect() | "Enable Pathogen
Here you have two commands in a row, and the second one is a pure comment.
However, I suggest always write comments on separate lines and not to mess with this stuff at all.

syntax error near unexpected token `newline' for my nnoremap in .vimrc?

Here is the configuration of my .vimrc.
For the 12 th line.
nnoremap <F12> :!/opt/google/chrome/chrome '%:p'<CR>
source .vimrc
bash: /home/debian9/.vimrc: line 12: syntax error near unexpected token `newline'
bash: /home/debian9/.vimrc: line 12: `nnoremap <F12> :!/opt/google/chrome/chrome '%:p'<CR>'
How to fix it ?
Don't use source in your Bash shell; the right command is :source .vimrc inside Vim!
Please note that reloading your Vim configuration may work, or not (depending what you do, how you define :autocmds, whether the changed configuration affects already loaded plugins). If in doubt, it's easier to just :quit Vim and restart it; the new .vimrc will then be loaded automatically.
The syntax of your Vim configuration in ~/.vimrc is Vimscript; this is only understood by Vim itself. Your shell configuration would be put in (for example) ~/.bashrc; you can source that in your shell.

Syntastic installation issue: ^M file endings

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

How do I get the standard Vim FTP command to work?

When I do vim ftp://[user#]machine/path in Vim I get this error: E683: File name missing or invalid pattern. Why id Vim treating this command as a search pattern?
I'm getting the same error in MacVim and Terminal Vim.
Usually you want to start Vim and then edit a file over ftp. Calling vim with a url may not work. You're supposed give a file path as argument to vim and that's what's causing the error.
Also, the error says:
File name missing or invalid pattern
Vim is not treating it as a search pattern. Notice the "or". It happens that no file name is given.
Try starting vim and then:
:e ftp://[user#]machine/path

Resources