The snippet below has been in my vimrc for quite some time, recently (in the latest versions of vim) I am getting an error in the forth line:
set listchars=tab:▸\ ,trail:◇,extends:»,precedes:«,eol:¬ " show tabs et. al.
I have not made any changes to my vimrc file and yet now I am getting this error:
Error detected while processing $HOME/.vim/rcfiles/editing:
line 11:
E474: Invalid argument: listchars=tab:�~V�\ ,trail:�~W~G,extends:»,precedes:«,eol:¬
line 11 is the 4th line in the snippet.
set list " show invisibles
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,eol:$ " show tabs et. al.
if v:version >= 703
set listchars=tab:▸\ ,trail:◇,extends:»,precedes:«,eol:¬ " show tabs et. al.
if (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8')
let &listchars="tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u00b7,eol:\u00ac"
let &listchars="tab:\u25b8 ,trail:\u25c7,extends:\u00bb,precedes:\u00ab,nbsp:\u00b7,eol:\u00ac"
endif
I haven't yet tried to go back to older versions where it works but I know that the error is thrown in version 8.0.1453 on one machine and version 8.2.2100 on another.
Oddly, if I type (or copy and paste) this line into vim, it is accepted with no problem, but in my vimrc I get an error on startup.
Any ideas?
Related
I'm using Vim on Cygwin and I've recently decided to attempt to install some plugins. I installed Vundle and managed to get the vim-airline plugin working, but for some reason I cannot get Syntastic to work.
My vimrc:
set nocompatible
filetype off
set rtp+=c:/cygwin64/home/USERNAME/.vim/bundle/Vundle.vim
call vundle#begin('c:/cygwin64/home/USERNAME/.vim/bundle/')
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'vim-syntastic/syntastic'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
call vundle#end()
filetype plugin indent on
I believe syntastic downloaded properly as it updates when I run :PluginInstall and :PluginUpdate from within Vim.
When I open a .py file with the .vimrc above, I receive the following error:
syntastic: error: checker python/python returned abnormal status 2
From sniffing around I learned that from within Vim, the following can be helpful in diagnosing syntastic problems.
:let g:syntastic_debug=3
:w
:mes
One of the portions of the :mes returns
syntastic: 73.033500: checker output: ['C:\Python36\python.exe: can''t open file ''/home/USERNAME/.vim/
bundle/syntastic/syntax_checkers/python/compile.py'': [Errno 2] No such file or directory', '']
After a little more digging I found that my shellslash variable may not be set, which is causing Windows filepaths to be interpreted as UNIX filepaths (or vice versa). Other people found this portion of the :mes return helpful:
syntastic: 72.928500: &shell = '/bin/bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellqu
ote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape
= ''
I added a line to my .vimrc, set shellslash, yet after I saved it and reopened vim, nothing changed (I tried adding it in several different places, like before the set rtp, after syntastic plugin call, and at the very end). I got the same error, and when I ran through the prompts for :mes again, there was no shellslash variable listed. The output looked exactly like above. I also tried :set shellslash from within Vim, and while no errors were thrown, the problem remained.
The last thing I could think of was that Vim was loading a different .vimrc file, so I ran :scriptnames but it returned in the top row the location of the .vimrc I've been editing.
So how do I set shellslash? I believe that might allow Syntastic to work properly in Vim on Cygwin.
System = OSX 10.9.4
I am trying to turn on syntax highlighting in vim while using the terminal. However, I am unable to get it to work properly.
Things I've tried:
located the vimrc file and added the following code:
set ai " auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position
syntax on " syntax highlighting
set hlsearch " highlight the last searched term
filetype plugin on " use the file type plugins
Located vimrc under directory:
cd /usr/share/vim/
The interesting thing is that once I add the code to the vimrc using vim, followed by exiting (x), and re-opening the file again, syntax is correctly highlighted in the vimrc.
However, when I try to make a new vim file called "test", copy the same code, save and exit. Re-open it, the syntax is not highlighted at all.
It appears that syntax highlighting only works when I open the actually vimrc file---and not when I try to create a new one or open another file that should have syntax highlighting.
I've also tried to create a .vimrc (exact copy) under the ~/ (directory). No success.
Made a new file called "test" and tried turning it on while active as well:
vim test
"then within vim"
:syntax on
I am really confused as to why this partially works.
Any help is much appreciated.
Cheers!
p.s. I have followed these instructions as well from: http://geekology.co.za/article/2009/03/how-to-enable-syntax-highlighting-and-other-options-in-vim
*I am aware of macvim, but would like a solution for the native vim in terminal. Thanks.
NEVER do anything in $VIM as it will work only by luck, cause unexpected behaviors and likely be overwritten next time Vim is updated.
What you have put in /usr/share/vim/vimrc should be in ~/.vimrc.
filetype on and syntax on are the bare minimum you need in your ~/.vimrc for syntax highlighting to work.
$ vim ~/.vimrc gives you syntax highlighting because the file is recognized by Vim as a vim file. Filetype detection is mostly dependent on file extensions so you can't expect any syntax highlighting in a file called test.
$ vim test.py, on the other hand, should give you syntax highlighting.
If the filetype is not detected, you can force it with :set filetype=python.
You most probably want to enable indentation along with syntax highlighting, so add these to lines to ~/.vimrc
filetype plugin indent on
syntax on
Steps with screenshots can be found here
http://osxandiosdaily.com/how-to-enable-vim-syntax-highlighting-on-mac-osx/
Inside of your file, enter command mode and enter the command
:syntax on
I tote the same .vimrc between machines that have both Vim 7.2 and 7.3 installed. The machines with Vim 7.2 complain about my 7.3-specific options every time I open a file:
Error detected while processing /home/spiffytech/.vimrc:
line 72:
E518: Unknown option: rnu
line 73:
E518: Unknown option: undofile
line 74:
E518: Unknown option: undodir=/tmp
line 75:
E518: Unknown option: cryptmethod=blowfish
Press ENTER or type command to continue
How can I make Vim ignore these errors and not prompt me to hit enter whenever I open files?
It might be worth doing more fine-grained checking for actual supported features rather than versions.
E.g.:
if has('persistent_undo')
set undofile
set undodir=/tmp
endif
" Some options can only be checked with exists('+option'); I'm not sure why
if exists('+relativenumber')
set rnu
endif
if has('cryptv')
set cryptmethod=blowfish
end
Wrap the new options in:
if version >= 703
set rnu ...
endif
Check the help for v:version for more info on the version number to use:
*v:version* *version-variable*
v:version Version number of Vim: Major version number times 100 plus
minor version number. Version 5.0 is 500. Version 5.1 (5.01)
is 501. Read-only. "version" also works, for backwards
compatibility.
Use |has()| to check if a certain patch was included, e.g.: >
if has("patch123")
< Note that patch numbers are specific to the version, thus both
version 5.0 and 5.1 may have a patch 123, but these are
completely different.
Sometimes an option is legitimate, but not available in the current environment. For example:
$ vi
Error detected while processing /home/username/.vimrc:
line 9:
Unknown option: indentexpr=
To test whether an option exists or not, and avoid an error if not available:
if exists("&indentexpr")
:set indentexpr=
endif
You can ignore any error with silent! ..., like silent! set undofile
In you .vimrc, you can test against the Vim version you are executing.
See help v:version
if v:version >= 703
"do something
set rnu
set undofile
...
endif
703 corresponds to Vim 7.3 (which is not really intuitive...)
I would say this question is not answered. Consider a Session.vim created on computer A which has the later vim version. In source control when another computer B tries to open the Session.vim the errors are triggered. It makes no sense to have to manually wrap a version number for what should be an automated process. With this behaviour the new version would have to automatically wrap a new command in a version number when saving a session - something which 7.3 does not do.
So I am really new to VIM but was attempting to add some plugin's one of which is EasyMotion.
According to the vid tutorials at NetPlus, and Vim's Wiki Plugin Page, after dropping the plugin's .vim file in the plugins direction (on Windows) I should be able to initiate the EasyMotion plugin by hitting (from within a loaded file):
<Leader><Leader>w"
And according to the VIM documentation, Leader is set to the mapleader variable which is by default "\" unless change. I haven't changed it but hitting "\" does nothing but beep (windows error bell).
I did try even mapping:
let mapleader = ","
let g:mapleader = ","
and nothing changed.
UPDATE
I came across these errros when I accidently tried loading my _vimrc file by Vim (right clicked on file and chose to open with Vim) -> I think this might give some insight, but I haven't a clue why:
ERROR
Error detected while processing d:\Program Files (x86)\Vim\vimfiles\plugin\
EasyMotion.vim:
line 24:
E117: Unknown function: EasyMotion#InitOptions
line 39:
E121: Undefined variable: g:EasyMotion_hl_group_target
E116: Invalid arguments for function EasyMotion#InitHL
line 40:
E121: Undefined variable: g:EasyMotion_hl_group_shade
E116: Invalid arguments for function EasyMotion#InitHL
line 69:
E117: Unknown function: EasyMotion#InitMappings
I don't use the aforementioned plugin, so cannot help with it specifically, but as far as the other part goes, you can see what your leader is mapped by
:echo g:mapleader
Vim plugins are usually (if you're not using some plugin to manage plugins, like Pathogen or Vim-Addon-Manager) saved either in $VIM\plugins (bad), or in $VIMFILES\plugins (good), on Windows. If you're on unix, just replace \ with /.
You can also find out where your $VIM, $VIMFILES ... directories are by echoing them ... :echo $VIMFILES.
One more thing about mapleader. It is not dynamic - that is, once the mapping is defined with
<leader>some_key
and you change the leader variable, it does not redefine the mapping. So your leader has to change (for example, in your vimrc) before the actual mapping that is using it happens.
The answer came out to be that I had not added the autoload .vim file to the autoload directory. This was why I was getting the specific errors.
In my .vimrc I have the following snippet:
if has('autocmd')
filetype plugin indent on
syntax on
but when I start vim it shows the following error:
Can't open file /usr/share/vim/syntax/syntax.vim
error seems to have occurred on syntax on line in .vimrc.
I do not have syntax.vim in path /usr/share/vim/syntax though I have others like clojure.vim cpp.vim java.vim etc...
I searched but can't seem to find the default syntax.vim if it comes with default version of vim.
I've been stuck with this for a while and would like some help.
I use Arch and build vim from the AUR using the vim-git PKGBUILD. For me, it was the case of using vim-git, but vim-runtime from the official repos, not vim-runtime-git from the AUR.
Switching to vim-runtime-git solved this issue for me and provided the syntax file (and colours, and...).
It should be there so there may be other files missing. I would suggest you re-install!.
For a QDF here is what the
syntax.vim file should look like this:-
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last Change: 2001 Sep 04
" This file is used for ":syntax on".
" It installs the autocommands and starts highlighting for all buffers.
if !has("syntax")
finish
endif
" If Syntax highlighting appears to be on already, turn it off first, so that
" any leftovers are cleared.
if exists("syntax_on") || exists("syntax_manual")
so <sfile>:p:h/nosyntax.vim
endif
" Load the Syntax autocommands and set the default methods for highlighting.
runtime syntax/synload.vim
" Load the FileType autocommands if not done yet.
if exists("did_load_filetypes")
let s:did_ft = 1
else
filetype on
let s:did_ft = 0
endif
" Set up the connection between FileType and Syntax autocommands.
" This makes the syntax automatically set when the file type is detected.
augroup syntaxset
au! FileType * exe "set syntax=" . expand("<amatch>")
augroup END
" Execute the syntax autocommands for the each buffer.
" If the filetype wasn't detected yet, do that now.
" Always do the syntaxset autocommands, for buffers where the 'filetype'
" already was set manually (e.g., help buffers).
doautoall syntaxset FileType
if !s:did_ft
doautoall filetypedetect BufRead
endif
I had this problem as well after upgrading to 7.3 (I'm using cygwin). Check whether running "vi" instead of "vim" has the same problem. I found that vim was actually the old 7.2 executable, but the syntax files were in the location expected by 7.3; vi was the correct 7.3 executable.
I have been using compiled vim from source without explicitly installing it on my system (due to missing sudo privileges).
I was able to solve the issue by adding the following line to my .bashrc:
export VIMRUNTIME=<path to cloned vim repo>/runtime
Thus: Pointing this env variable to the runtime director in the git tree, makes vim find the needed file(s).