SOLVED: bad colorscheme .vim file.
Whenever I start up vim, I always get a flood of errors and then a "Press ENTER or type command to continue" message. Then vim works fine.
I just have no idea what the cause of it is.I am on a Linux machine.
line 5045:
E488: Trailing characters: </div>
line 5048:
E488: Trailing characters: <script crossorigin=
line 5049:
E488: Trailing characters: <script async=
line 5052:
E488: Trailing characters: <script async src=
line 5053:
E488: Trailing characters: </body>
line 5054:
E488: Trailing characters: </html>
Press ENTER or type command to continue
Here is my .vimrc file. It is just the example one with some editing. I am still a beginner.
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last change: 2011 Apr 15
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
syntax enable
colorscheme solarized
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
execute pathogen#infect()
set nopaste
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set number
Vim complains about HTML tags, so it looks like you've installed a bad Vimscript, grabbing a (formatted) web page instead of the raw contents.
Either go back to the page and copy/paste from the browser, or (e.g. in GitHub) get the raw file contents and save that.
Related
In vim, frequently when I perform a ':help ' command, I get an error. Here's an error I see when I perform ':help tags' for example:
"tagsrch.txt.gz" [readonly][noeol] 42L, 11288C
Error detected while processing function gzip#read:
line 51:
E303: Unable to open swap file for "/usr/share/vim/vim74/doc/tagsrch.txt.gz", recovery impossible
41 fewer lines
Press ENTER or type command to continue
When I press enter, the help comes up as desired, but this is still a nuisance. What have I done wrong? My google-foo is apparently too weak for this because I don't see other people complaining about this.
Is this because I have this set for my swap directory?
set directory=~/.vim/swap,.
Let me know if it would be helpful to paste my entire vimrc. I'm on rhel7 with vim 7.4, in case it's helpful.
Here's my ~/.vimrc:
" vim:softtabstop=4:shiftwidth=4:et
" Tab preferences
set shiftwidth=4
set softtabstop=4
set autoindent
set expandtab
execute pathogen#infect()
" Where to store swap files. By default, they will go into ~/.vim/swap, but
" if that doesn't work, they will go in cwd.
set directory=~/.vim/swap,.
filetype plugin indent on " enables filetype indent specific plugins
" Instructions on how to tab complete filenames.
" set wildmode=longest,list,full
set wildmode=longest,list
set wildmenu
" In case there are vim modelines at the top of the file, as there
" is with this one.
set modeline
" Always show the status line.
set laststatus=2
" Look for a tags file.
set tags=./tags,tags;
" Also search for .git/tags files.
set tags^=./.git/tags,*/.git/tags;~
" Make Ctrl-] show the list of options by default.
nnoremap <C-]> g<C-]>
nnoremap <C-w><C-]> <C-w>g<C-]>
" Colors
" Have syntax highlighting in terminals which can display colours:
if has('syntax') && (&t_Co > 2)
syntax on
else
syntax off
endif
set background=dark
set hlsearch
set incsearch
" I so often type teh instead of the.
abbreviate teh the
" To help vim deal with pasting text
:map <F9> :set invpaste <CR>
set pt=<F9>
" Toggle vim's spell checker with <F5>
:map <F5> :setlocal spell! spelllang=en_us<cr>
" Shortcuts for c code.
map! ,bc /* */^[hhi
map! ,bz #if 0^M#endif /* 0 */^[O
" Ignore whitespace when diffing files.
map ,iw :set diffopt+=iwhite<CR>
set path^=/home/bneradt/work/trafficserver/**
In my situation / partition is full. Cleaned it and it works now.
When I look at a file on one of our servers I see something like this:
<feff>sku;qty
productsku;1
When I download the file and open it with vi I don't see the <feff>
When I do :e ++bin I can see the <feff> but I also see ^M now
<feff>sku;qty^M
productsku;1^M
But I don't want to set the ^M. I just want to see the <feff>.
Another example is <80> which I had in another file.
How can I set up vim to show me those special chars?
~ EDIT ~
The command vi --version tells me the following:
VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:08)
It also says that the system-vimrc-file is /etc/vimrc which has the following content:
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=utf-8,latin1
endif
set term=builtin_ansi
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
I copied this and added it to my ~/.vimrc but none of these changes does what I want. A few things are in if cases so I might have to play around with these too.
Does anyone know if there are other files than the one stated in vi --version that will be read when editing a file?
:help 'bomb' explains Vim's behavior:
When Vim reads a file and 'fileencodings' starts with "ucs-bom", a
check for the presence of the BOM is done and 'bomb' set accordingly.
Unless 'binary' is set, it is removed from the first line, so that you
don't see it when editing.
So,
:set fencs-=ucs-bom
would turn this off, but then the encoding detection is broken, too! According to my experiments, explicit encoding setting (via :edit ++enc=ucs2-le) also sets 'bomb' and removes the <feff> mark. So, this avenue leads nowhere.
Alternatives
Editing in binary mode, as you've found out. I wouldn't recommend it, since it has drawbacks.
Including the indication in the statusline. You have to look somewhere else, but it's always visible, not just at the beginning of the document. Highly recommended as the right way™ in Vim. And easy to achieve, too:
set statusline+=\ %{&bomb?'BOM':''}
So vim just suddenly started flaking out on me today and I can't pinpont the problem. Haven't touch the configuration file and the last thing I worked on before I noticed the problem was updating my sshd_config and sshd_config.pacnew files.
What I noticed is that upon opening the sshd_config file is vim starting out in insert mode and automatically inserted a series special characters wherever the curser was at the moment. So it overwrites information in configuration files. I guess that can become somewhat problematic =)
So if I start a new file touch test_vim && vim test_vim this is what I see:
:bfff/00fe/00fe/13fe[>85;95;0c
I have a feeling this is going to be one of those things that's really stupid and I completely overlooked. Does anyone have any idea what's going on?
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last change: 2014 Feb 05
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
set undofile " keep an undo file (undo changes after closing)
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
This is a recent Vim bug. You should probably roll back to an earlier release while a proper fix is worked on.
You can have a look about changing the vim configuration files on this post
this is the official vim wiki page
Vim wiki
So the bug seems to affect urxvt terminals running with transparency. Using a different terminal, or in my case disabling transparency via /.Xresources will temporarily solve the issue until they release a patch.
I looked around but haven't found an answer to this. I have a CentOS 6.2 server running with the same .vimrc as my CentOS 5.8 server, however when I hit enter in VIM on my 6.2 server, it adds the first character of the previous line if it's a certain character (% or # are the ones I've seen). This is what happens in VIM (The seconds lines are right after hitting enter, but without typing anything else):
# <enter>
#
% <enter>
%
Here's my .vimrc:
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set showmatch
set number
imap jj <Esc> " Professor VIM says '87% of users prefer jj over esc', jj abrams disagrees
" Indenting *******************************************************************
set ai " Automatically set the indent of a new line (local to buffer)
set si " smartindent (local to buffer)
" Cursor highlights ***********************************************************
"set cursorline
"set cursorcolumn
" Set an orange cursor in insert mode, and a red cursor otherwise.
" Works at least for xterm and rxvt terminals.
" Does not work for gnome terminal, konsole, xfce4-terminal.
"if &term =~ "xterm\\|rxvt"
" :silent !echo -ne "\033]12;red\007"
" let &t_SI = "\033]12;orange\007"
" let &t_EI = "\033]12;red\007"
" autocmd VimLeave * :!echo -ne "\033]12;red\007"
"endif
" Searching *******************************************************************
set hlsearch " highlight search
set incsearch " Incremental search, search as you type
set ignorecase " Ignore case when searching
set smartcase " Ignore case when searching lowercase
" Colors **********************************************************************
"set t_Co=256 " 256 colors
set background=dark
syntax on " syntax highlighting
"colorscheme darkzen
Ran a diff against it and the one on my 5.8 server (where I don't have this problem) and there was no difference at all. Any idea why this may be happening?
It looks like automatic comment insertion.
Take a look at :help formatoptions and :set formatoptions. These are probably being set by file type.
Run verbose set formatoptions. You should get back a string that contains 'r', which Automatically inserts the current comment leader after hitting <Enter> in Insert mode. The verbose bit should point you at the file(likely a filetype plugin) who is the culprit.
I prevent vim from hijacking my formatoptions via the autocommand au FileType * set formatoptions=lq in my vimrc. Most of the options drive me absolutely crazy, although r and o are by far the worst.
I am getting garbage characters on pressing of arrow keys when I open a vim file.
I have also defined following in my ~/.vimrc:
set nocompatible
I am using putty for login. Is this a putty issue?
Please help
EDIT: if I remove my ~/.vimrc, then problem is also removed.
I have used following code as .vimrc file, and it has resolved all my problem.
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
Just save the above text as
.vimrc