假设GVIM装在D盘目录GVIM里面。
首先,找到目录D:\GVIM\GVimPortable\App\DefaultData\settings,里面有一个文件vimrc,这个跟ubuntu下的vimrc基本上是一样的,只不过有一些地方不太一样。由于GVIM中的vimrc里面的程序使得该gvim界面拥有菜单之类的东东,所以只能够在后面把我在linux下的vimrc添加,
然后把我自己的配置全部粘上去了,配置文件的详情请看上一篇博文http://www.cnblogs.com/yejinru/archive/2012/11/19/2777970.html
但是84-85行中会报错:
所以我们得要把它注释掉
" command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
" \ | wincmd p | diffthis
然后发现vimrc的菜单栏消失了,我们一行行代码往下看,发现在我的配置上面366行到377行(如下的代码)把菜单给注释掉了,然后我们把他们都注释掉就行了。
"""""""""""""""""""""""""""""""""""""""""""""""""""
"菜单栏、工具栏显示与隐藏的切换
"""""""""""""""""""""""""""""""""""""""""""""""""""
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>
这时,虽然菜单栏出来了,但是发现菜单的文字由原来的汉字全部成为了乱码- -
无奈之下,我们继续改。
找到第一行(我的配置文件)
set encoding=utf-8
set termencoding=utf-8
set fileencodings=utf-8,chinese,latin-1
发现他用的是utf-8码,而在gvim下用的不是这种编码,所以把他们注释掉就好了。
这时,基本上把我的ubuntu下的配置文件同步到了wim下了^_^
但是那个F9在ubuntu上面是可以直接编译以及运行,在wim下我发现即使添加了环境变量,还是不能够直接编译运行,如果谁知道的话,欢迎补充^^。
字体的大小设置如下
" 设置字体的大小 set guifont=Courier\ New:h16
附上我的GVIM的vimrc文件
" An example for a vimrc file. " " Maintainer: Bram Moolenaar <[email protected]> " Last change: 2006 Nov 16 " " 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 then 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 " In many terminal emulators the mouse works just fine, thus enable it. set mouse=a " 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). autocmd BufReadPost * \ if line("'\"") > 0 && 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. " command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis " \ | wincmd p | diffthis " here " 设置字体的大小 set guifont=Courier\ New:h16 " set encoding=utf-8 " set termencoding=utf-8 " set fileencodings=utf-8,chinese,latin-1 if has("win32") set fileencoding=chinese else set fileencoding=utf-8 endif language messages zh_CN.utf-8 " 设定不与以前版本兼 set nocompatible " 设置配色方案 colorscheme ir_black " 显示行号 set nu " 侦测文件类型 filetype on " 设置当文件被改动时自动载入 set autoread " 记录历史的行数 set history=100 " 显示语法高亮 syntax enable syntax on " 在处理未保存或只读文件的时候,弹出确认 set confirm " 与windows共享剪贴板 set clipboard+=unnamed " 载入文件类型插件 filetype plugin on " 为特定文件类型载入相关缩进文件 filetype indent on " 保存全局变量 set viminfo+=! " 带有如下符号的单词不要被换行分割 set iskeyword+=_,$,@,%,#,- " 设置鼠标一直可用 set mouse=a " 高亮当前行 set cursorline " 命令行高度 set cmdheight=1 " 启动的时候不显示那个援助索马里儿童的提示 set shortmess=atI " 不让vim发出讨厌的滴滴声 set noerrorbells " 在被分割的窗口间显示空白,便于阅读 set fillchars=vert:\ ,stl:\ ,stlnc:\ """""""""""""""""""""""""""" " 文件设置 """""""""""""""""""""""""""" " 不要备份文件(覆盖文件时不备份) set nobackup " 不要生成swap文件,当buffer被丢弃的时候隐藏它 setlocal noswapfile set bufhidden=hide " 字符间插入的像素行数目 set linespace=0 " 增强模式中的命令行自动完成操作 set wildmenu " 置粘贴模式,使得粘贴不错位 " set paste " 保存文件,用习惯了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 showmatch " 高亮显示被找到的句子(phrases) "set hlsearch " 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索),即输入搜索内容时就显示搜索结果 set incsearch " 搜索时忽略大小写 set ignorecase " 不要闪烁 set novisualbell """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 文本格式和排版 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 自动格式化 set formatoptions=tcrqn " 继承前一行的缩进方式,特别适用于多行注释 set autoindent " 为C程序提供自动缩进 set smartindent " 使用C样式的缩进 set cindent " 制表符为4 set tabstop=4 " 统一缩进为4 " 使得按退格键时可以一次删掉 4 个空格 set softtabstop=4 " 设定 << 和 >> 命令移动时的宽度为 4 set shiftwidth=4 " 不要用空格代替制表符 set noexpandtab " 设置每行80个字符自动换行 set textwidth=80 " 自动切换当前目录为当前文件所在的目录 set autochdir " 折叠代码 set foldmethod=syntax " 文件打开时不折叠 set foldlevel=100 """"""""""""""""""""""""""""""""""""""""""" "自动实例括号 """"""""""""""""""""""""""""""""""""""""""" 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 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""" " set mapleader """""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = "," " platform function! MySys() if has("win32") return "windows" else return "linux" endif endfunction " if file not opened, create a new tab, or switch to the opened file function! SwitchToBuf(filename) " find in current tab let bufwinnr = bufwinnr(a:filename) if bufwinnr != -1 exec bufwinnr . "wincmd w" return else " search each tab tabfirst let tb = 1 while tb <= tabpagenr("$") let bufwinnr = bufwinnr(a:filename) if bufwinnr != -1 exec "normal " . tb . "gt" exec bufwinnr . "wincmd w" return endif tabnext let tb = tb +1 endwhile " not exist, new tab exec "tabnew " . a:filename endif endfunction " fast edit .vimrc if MySys() == 'linux' " fast reloading of the .vimrc map <silent> <leader>ss :source ~/.vimrc<cr> " fast editing of the .vimrc map <silent> <leader>ee :call SwitchToBuf("~/.vimrc")<cr> " when .vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc elseif MySys() == 'windows' " Set helplang set helplang=cn "Fast reloading of the _vimrc map <silent> <leader>ss :source ~/_vimrc<cr> "Fast editing of _vimrc map <silent> <leader>ee :call SwitchToBuf("~/_vimrc")<cr> "When _vimrc is edited, reload it autocmd! bufwritepost _vimrc source ~/_vimrc endif if MySys() == 'windows' source $VIMRUNTIME/mswin.vim behave mswin endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""" " 插件 """"""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""" "加入工程使得能够访问ctags """""""""""""""""""""""""""""" "project1" set tags=tags set autochdir "后面的工程加在tags变量上 """""""""""""""""""""""""""""" " 设置Taglist """""""""""""""""""""""""""""" " 按照名称排序 let Tlist_Sort_Type = "name" " 在右侧显示窗口 let Tlist_Use_left_Window = 1 " 如果只有一个buffer,kill窗口也kill掉buffer let Tlist_Exist_OnlyWindow = 1 " 使taglist只显示当前文件tag,其它文件的tag都被折叠起来(同时显示多个文件中的tag时) let Tlist_File_Fold_Auto_Close = 1 " 不要显示折叠树 let Tlist_Enable_Fold_Column = 1 "不同时显示多个文件的tag,只显示当前文件的 let Tlist_Show_One_File = 1 " 键盘映射 nmap tl :TlistToggle<cr> """"""""""""""""""""""""""""""""""""""""""""" "设置 winManager winManager管理netrw和Taglist。 """"""""""""""""""""""""""""""""""""""""""""" let g:winManagerWindowLayout = "FileExplorer|TagList" let g:persistentBehaviour = 0 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> nmap wm :WMToggle<cr> "设置 netrw """""""""""""""""""""""""""""" "let g:netrw_winsize = 30 "nmap <silent> <leader>fe :Sexplore!<cr> "let Tlist_File_Fold_Auto_Close=1 " 快速切换头文件/源文件 "nnoremap <silent><F12>:A<cr> ""nmap <silent><F12>:A<CR> "在工程中快速查找 "nnoremap <silent><F3>:Grep<cr> """""""""""""""""""""""""""""" "设置 MiniBufExploer """""""""""""""""""""""""""""" " quickfix模式 autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""" "F5编译和运行C++程序 "F6编译和运行C程序 """""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " C的编译和运行 map <F6> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w" exec "!gcc % -o %<" exec "! ./%<" endfunc " C++的编译和运行 map <F5> :call CompileRunGpp()<CR> func! CompileRunGpp() exec "w" exec "!g++ % -o %<" exec "! ./%<" endfunc 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 " 自动补全(ctrl-p)时的一些选项: 多于一项时显示菜单,最长选择; 显示当前选择的额外信息 if v:version >= 700 set completeopt=menu,longest,preview endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""" " 状态行相关动作 """"""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 显示状态栏 (默认值为 1, 无法显示状态栏) set laststatus=2 " 状态行颜色 highlight StatusLine guifg=SlateBlue guibg=Yellow highlight StatusLineNC guifg=Gray guibg=White function! CurDir() let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") return curdir endfunction """"""""""""""""""""""""""""""" "状态行显示内容 """"""""""""""""""""""""""""""" " %F 当前文件名 " %m 当前文件修改状态 " %r 当前文件是否只读 " %Y 当前文件类型 " %{&fileformat} 当前文件编码 " %b 当前光标处字符的 ASCII 码值 " %B 当前光标处字符的十六进制值 " %l 当前光标行号 " %c 当前光标列号 " %V 当前光标虚拟列号 (根据字符所占字节数计算) " %p 当前行占总行数的百分比 " %% 百分号 " %L 当前文件总行数 set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c " 设置在状态行显示的信息如下: " set nowrapscan "Highlight current if has("gui_running") set cursorline hi cursorline guibg=#333333 hi CursorColumn guibg=#333333 endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => 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 "How many tenths of a second to blink set mat=2 set lines=40 set columns=100 """""""""""""""""""""""""""""""""""""""""""""""""""" " 日历插件设置 """""""""""""""""""""""""""""""""""""""""""""""""""" " 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 endfunction
另外,我这个背景的颜色使用的是ir_black
在106行中
" 设置配色方案
colorscheme ir_black
大家自己可以设置一下自己喜欢的背景色。
那个背景色的种类在这个目录下D:\GVIM\GVimPortable\App\vim\vim71\colors
另外我这个背景色是从vim的资源网上下的,具体大家可以复制一个同样的文件,然后把他的名字改成ir_black(这个名字随意,但是得要跟上面的保持一致。。。),然后代码如下
"%% SiSU Vim color file " Slate Maintainer: Ralph Amissah <[email protected]> " (originally looked at desert Hans Fugal <[email protected]> http://hans.fugal.net/vim/colors/desert.vim (2003/05/06) :set background=dark :highlight clear if version > 580 hi clear if exists("syntax_on") syntax reset endif endif :hi Normal guifg=White guibg=grey15 :hi Cursor guibg=khaki guifg=slategrey :hi VertSplit guibg=#c2bfa5 guifg=grey40 gui=none cterm=reverse :hi Folded guibg=black guifg=grey40 ctermfg=grey ctermbg=darkgrey :hi FoldColumn guibg=black guifg=grey20 ctermfg=4 ctermbg=7 :hi IncSearch guifg=green guibg=black cterm=none ctermfg=yellow ctermbg=green :hi ModeMsg guifg=goldenrod cterm=none ctermfg=brown :hi MoreMsg guifg=SeaGreen ctermfg=darkgreen " 背景颜色 :hi NonText guifg=RoyalBlue guibg=grey15 cterm=bold ctermfg=blue :hi Question guifg=springgreen ctermfg=green :hi Search guibg=peru guifg=wheat cterm=none ctermfg=grey ctermbg=blue :hi SpecialKey guifg=yellowgreen ctermfg=darkgreen :hi StatusLine guibg=#c2bfa5 guifg=black gui=none cterm=bold,reverse :hi StatusLineNC guibg=#c2bfa5 guifg=grey40 gui=none cterm=reverse :hi Title guifg=gold gui=bold cterm=bold ctermfg=yellow :hi Statement guifg=CornflowerBlue ctermfg=lightblue :hi Visual gui=none guifg=khaki guibg=olivedrab cterm=reverse :hi WarningMsg guifg=salmon ctermfg=1 :hi String guifg=SkyBlue ctermfg=darkcyan :hi Comment term=bold ctermfg=11 guifg=grey40 :hi Constant guifg=#ffa0a0 ctermfg=brown :hi Special guifg=darkkhaki ctermfg=brown :hi Identifier guifg=salmon ctermfg=red :hi Include guifg=red ctermfg=red :hi PreProc guifg=red guibg=white ctermfg=red :hi Operator guifg=Red ctermfg=Red :hi Define guifg=gold gui=bold ctermfg=yellow :hi Type guifg=CornflowerBlue ctermfg=2 :hi Function guifg=navajowhite ctermfg=brown :hi Structure guifg=green ctermfg=green :hi LineNr guifg=grey50 ctermfg=3 :hi Ignore guifg=grey40 cterm=bold ctermfg=7 :hi Todo guifg=orangered guibg=yellow2 :hi Directory ctermfg=darkcyan :hi ErrorMsg cterm=bold guifg=White guibg=Red cterm=bold ctermfg=7 ctermbg=1 :hi VisualNOS cterm=bold,underline :hi WildMenu ctermfg=0 ctermbg=3 :hi DiffAdd ctermbg=4 :hi DiffChange ctermbg=5 :hi DiffDelete cterm=bold ctermfg=4 ctermbg=6 :hi DiffText cterm=bold ctermbg=1 :hi Underlined cterm=underline ctermfg=5 :hi Error guifg=White guibg=Red cterm=bold ctermfg=7 ctermbg=1 :hi SpellErrors guifg=White guibg=Red cterm=bold ctermfg=7 ctermbg=1
上面兩個文件的鏈接:
http://pan.baidu.com/share/link?shareid=416806&uk=3239296356
当然还可以自己改变一下自己喜欢的颜色的,具体的大家可以百度一下,有兴趣的话,还可以自己尝试一下的^_^
最后附上我的运行界面
2013.1.5日,发现吴垠学长一文《手把手教你把Vim改装成一个IDE编程环境(图文)》写的很详细,我上面的献丑了= =。
附上他的链接http://blog.csdn.net/wooin/article/details/1858917