|
|
我在用Win XP系统时就在使用VIM了,自己也整出了一个适合自己的配置文件,
现在在使用Archlinux当然就把Win下的配置文件复制过来,放在~/.vimrc里,但发现我运行VIM时提示了很多错误,真让人不明白了,难道Win下的VIM与Linux下的配置有很大的不同吗?
以下是错误信息:
- [lwkyy@Asins ~]$ vim
- 处理 /home/lwkyy/.vimrc 时发生错误:
- 第 1 行:
- E488: 多余的尾部字符: nocp^M
- 第 2 行:
- E474: 无效的参数: encoding=chinese^M
- 第 4 行:
- E15: 无效的表达式: has("win32")^M
- 第 267 行:
- E171: 缺少 :endif
- 请按 ENTER 或其它命令继续
复制代码
以下是我的配置文件的内容:
- set nocompatible
- set encoding=chinese
- set fileencodings=utf-8,chinese
- if has("win32")
- set fileencoding=chinese
- else
- set fileencoding=utf-8
- endif
- let &termencoding=&encoding
- "设置中文菜单 .UTF-8
- lan mes zh_CN
- set langmenu=zh_CN
- source $VIMRUNTIME/delmenu.vim
- source $VIMRUNTIME/menu.vim
- "设置中文帮助文档
- if version >= 603
- set helplang=cn
- endif
- source $VIMRUNTIME/vimrc_example.vim
- ""source $VIMRUNTIME/mswin.vim
- ""behave mswin
- set diffexpr=MyDiff()
- function MyDiff()
- let opt = '-a --binary '
- if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
- if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
- let arg1 = v:fname_in
- if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
- let arg2 = v:fname_new
- if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
- let arg3 = v:fname_out
- if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
- let eq = ''
- if $VIMRUNTIME =~ ' '
- if &sh =~ '\<cmd'
- let cmd = '""' . $VIMRUNTIME . '\diff"'
- let eq = '"'
- else
- let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
- endif
- else
- let cmd = $VIMRUNTIME . '\diff'
- endif
- silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
- endfunction
- set number " 显示行号
- set ruler " 打开状态栏标尺
- set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
- set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格
- set tabstop=4 " 设定 tab 长度为 4
- set nobackup " 覆盖文件时不备份
- syntax on " 自动语法高亮
- set autochdir " 自动切换当前目录为当前文件所在的目录
- set autoindent cindent cinoptions=g0
- " 打开自动缩进和 C 语言风格的缩进模式,
- " 定制 C 语言缩进风格
- set backspace=indent,eol,start
- " 不设定的话在插入状态无法用退格键和 Delete
- " 键删除回车符
- set whichwrap=b,s,<,>,[,] " 设定退格键、空格键以及左右方向键在行首行尾时的
- " 行为,不影响 h 和 l 键
- set backupcopy=yes " 设置备份时的行为为覆盖
- if v:version >= 700
- set completeopt=menu,longest,preview
- " 自动补全(ctrl-p)时的一些选项:
- " 多于一项时显示菜单,最长选择,
- " 显示当前选择的额外信息
- endif
- set wildmenu " 启动具有菜单项提示的命令行自动完成
- set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时
- " 仍保持对大小写敏感
- set incsearch " 输入搜索内容时就显示搜索结果
- set hlsearch " 搜索时高亮显示被找到的文本
- set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
- set cmdheight=1 " 设定命令行的行数为 1
- function! CurDir()
- let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
- return curdir
- endfunction
- set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
- " 设置在状态行显示的信息如下:
- " %F 当前文件名
- " %m 当前文件修改状态
- " %r 当前文件是否只读
- " %Y 当前文件类型
- " %{&fileformat}
- " 当前文件编码
- " %b 当前光标处字符的 ASCII 码值
- " %B 当前光标处字符的十六进制值
- " %l 当前光标行号
- " %c 当前光标列号
- " %V 当前光标虚拟列号 (根据字符所占字节数计算)
- " %p 当前行占总行数的百分比
- " %% 百分号
- " %L 当前文件总行数
- set textwidth=78 " 设置一行显示的字数
- colorscheme murphy " 设定背景为夜间模式
- set nowrapscan
- "Highlight current
- if has("gui_running")
- set cursorline
- hi cursorline guibg=#333333
- hi CursorColumn guibg=#333333
- endif
- "Omni menu colors
- hi Pmenu guibg=#333333
- hi PmenuSel guibg=#555555 guifg=#ffffff
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " => VIM userinterface
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "Set 7 lines to the curors - when moving vertical..
- set so=7
- "Do not redraw, when running macros.. lazyredraw
- set lz
- "Change buffer - without saving
- set hid
- "Set magic on
- set magic
- "No sound on errors.
- set noerrorbells
- set novisualbell
- set t_vb=
- "show matching bracets
- set showmatch
- "How many tenths of a second to blink
- set mat=2
- " Tag List设置 -- 显示函数列表
- nnoremap <silent> <F9> :TlistToggle<CR>
- let Tlist_Use_SingleClick=1
- let Tlist_File_Fold_Auto_Close=1
- """"""""""""""""""""""""""""""
- " winManager setting
- """"""""""""""""""""""""""""""
- let g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList"
- let g:winManagerWidth = 30
- let g:defaultExplorer = 0
- nmap <C-W><C-F> :FirstExplorerWindow<cr>
- nmap <C-W><C-B> :BottomExplorerWindow<cr>
- nmap <silent> <F8> :WMToggle<cr>
- """"""""""""""""""""""""""""""
- " netrw setting
- """"""""""""""""""""""""""""""
- let g:netrw_winsize = 30
- nmap <silent> <leader>fe :Sexplore!<cr>
- let Tlist_File_Fold_Auto_Close=1
- " let g:template_load = 1
- " let g:template_tags_replacing = 1
- " let g:T_AUTHOR = "Asins"
- " let g:T_AUTHOR_EMAIL = "asinsimple@gmail.com"
- " let g:T_AUTHOR_WEBSITE = "http://www.studynote.cn"
- " let g:T_DATE_FORMAT = "%c"
- "自动实例括号
- inoremap ( ()<ESC>i
- inoremap ) <c-r>=ClosePair(')')<CR>
- inoremap { {}<ESC>i
- inoremap } <c-r>=ClosePair('}')<CR>
- inoremap [ []<ESC>i
- inoremap ] <c-r>=ClosePair(']')<CR>
- inoremap < <><ESC>i
- inoremap > <c-r>=ClosePair('>')<CR>
- " inoremap ' ''<ESC>i
- " inoremap " ""<ESC>i
- function ClosePair(char)
- if getline('.')[col('.') - 1] == a:char
- return "\<Right>"
- else
- return a:char
- endif
- endf
- " 保存文件,用习惯了Ctrl+S了
- " nmap <C-s> <esc>:w<CR>
- " imap <C-s> <esc>:w<CR>
- noremap <C-S> :update<CR>
- vnoremap <C-S> <C-C>:update<CR>
- inoremap <C-S> <C-O>:update<CR>
- set lines=40
- set columns=100
- "菜单栏、工具栏显示与隐藏的切换
- set guioptions-=T
- set guioptions-=m
- map <silent> <F4> :if &guioptions =~# 'T' <Bar>
- \set guioptions-=T <Bar>
- \set guioptions-=m <bar>
- \else <Bar>
- \set guioptions+=T <Bar>
- \set guioptions+=m <Bar>
- \endif<CR>
- " Tabs 的快捷键设置
- set guifont=YaHei\ Console\ Hybrid\ 12
- set fileencodings=utf-8,gb2312,utf-16,big5
- set textwidth=200
- let g:WC_min_len=3 " 当输入到第3个字母时才自动补全,自己可以改变之.
- autocmd BufEnter * call DoWordComplete() " 每个buffer自动启用自动补全filetype plugin o
- " Python 文件的一般设置,比如不要 tab 等
- autocmd FileType python setlocal et | setlocal sta | setlocal sw=4
-
- " 日历插件设置
- " let g:calendar_diary = /calendar
- " map ca :Calendar<cr>
- " 让 gvim 支持 Alt+n 来切换标签页
- function! BufPos_ActivateBuffer(num)
- let l:count = 1
- for i in range(1, bufnr("$"))
- if buflisted(i) && getbufvar(i, "&modifiable")
- if l:count == a:num
- exe "buffer " . i
- return
- endif
- let l:count = l:count + 1
- endif
- endfor
- echo "No buffer!"
- endfunction
- function! BufPos_Initialize()
- for i in range(1, 9)
- exe "map <M-" . i . "> :call BufPos_ActivateBuffer(" . i . ")<CR>"
- endfor
- exe "map <M-0> :call BufPos_ActivateBuffer(10)<CR>"
- endfunction
- autocmd VimEnter * call BufPos_Initialize()
- " 按F11键让VIM全屏
- if has('gui_running') && has("win32")
- map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
- endif
复制代码
不知为什么提示说条一行就有错,真不知是哪里有错了,请知道的朋友提点一下吧!先谢谢了! |
|