我的Vimrc
来源:互联网 发布:华劲集团待遇知乎 编辑:程序博客网 时间:2024/05/26 09:56
本文出自:http://blog.csdn.net/svitter
本地不再更新,迁移至Svtter的github
自己的vimrc。。功能很少,持续更新。
目前支持缩进4个空格,高亮。
用了gvim的example,和bluedust的部分配置文件,用于C++的编辑。
" An example for a vimrc file."" Maintainer:Bram Moolenaar <Bram@vim.org>" Last change:2008 Dec 17"" 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" finishendif" Use Vim settings, rather than Vi settings (much better!)." This must be first, because it changes other options as a side effect.set nocompatible" Make Tab 4 spaceset ts=4set expandtabset autoindent"" allow backspacing over everything in insert modeset backspace=indent,eol,startset background=darkset guifont=Consolas:h11hi clear hi Boolean guifg=#dca3a3 gui=boldhi Character guifg=#dca3a3 gui=boldhi Comment guifg=#7f7f7fhi Condtional guifg=#8fffffhi Constant guifg=#dca3a3 gui=boldhi Cursor guifg=#000000 guibg=#aeaeaehi Debug guifg=#dca3a3 gui=boldhi Define guifg=#ffcfaf gui=boldhi Delimiter guifg=#8f8f8fhi DiffAdd guibg=#613c46hi DiffChange guibg=#333333hi DiffDelete guifg=#333333 guibg=#464646 gui=nonehi DiffText guifg=#ffffff guibg=#1f1f1f gui=boldhi Directory guifg=#ffffff gui=boldhi Error guifg=#000000 guibg=#00ffffhi ErrorMsg guifg=#000000 guibg=#00c0cfhi Exception guifg=#8fffff gui=underlinehi Float guifg=#9c93b3hi FoldColumn guifg=#dca3a3 guibg=#464646hi Folded guifg=#dca3a3 guibg=#333333hi Function guifg=#ffff8fhi Identifier guifg=#ffffffhi Include guifg=#ffcfaf gui=boldhi IncSearch guifg=#000000 guibg=#c15c66hi Keyword guifg=#ffffff gui=boldhi Label guifg=#8fffff gui=underlinehi LineNr guifg=#7f7f7f guibg=#464646hi Macro guifg=#ffcfaf gui=boldhi ModeMsg guifg=#dca3a3 gui=boldhi MoreMsg guifg=#ffffff gui=boldhi NonText guifg=#1f1f1fhi Normal guifg=#cccccc guibg=#3f3f3fhi Number guifg=#aca0a3hi Operator guifg=#ffffffhi PreCondit guifg=#dfaf8f gui=boldhi PreProc guifg=#ffcfaf gui=boldhi Question guifg=#ffffff gui=boldhi Repeat guifg=#8fffff gui=underlinehi Search guifg=#000000 guibg=#c15c66hi SpecialChar guifg=#dca3a3 gui=boldhi SpecialComment guifg=#dca3a3 gui=boldhi Special guifg=#7f7f7fhi SpecialKey guifg=#7e7e7ehi Statement guifg=#8fffffhi StatusLine guifg=#333333 guibg=#f18c96hi StatusLineNC guifg=#333333 guibg=#cccccchi StorageClass guifg=#ffffff gui=boldhi String guifg=#cc9393hi Structure guifg=#ffffff gui=bold,underlinehi Tag guifg=#dca3a3 gui=boldhi Title guifg=#ffffff guibg=#333333 gui=boldhi Todo guifg=#ffffff guibg=#000000 gui=boldhi Typedef guifg=#ffffff gui=bold,underlinehi Type guifg=#ffffff gui=boldhi VertSplit guifg=#333333 guibg=#cccccchi Visual guifg=#333333 guibg=#f18c96 gui=reversehi VisualNOS guifg=#333333 guibg=#f18c96 gui=bold,underlinehi WarningMsg guifg=#ffffff guibg=#333333 gui=boldhi WildMenu guifg=#000000 guibg=#dca3a3if has("vms") set nobackup" do not keep a backup file, use versions insteadelse set backup" keep a backup fileendifset history=50" keep 50 lines of command line historyset ruler" show the cursor position all the timeset showcmd" display incomplete commandsset 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 formattingmap 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=aendif" 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 hlsearchendif" 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 ENDelse set autoindent" always set autoindenting onendif " 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 | diffthisendif
以上是在windows下的gvim配置文件.
14.05.13更新了字体Courier 10 Pitch,行号(适用于linux):
" An example for a vimrc file."" Maintainer:Bram Moolenaar <Bram@vim.org>" Last change:2008 Dec 17"" 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" finishendif" Use Vim settings, rather than Vi settings (much better!)." This must be first, because it changes other options as a side effect.set nocompatible" Make Tab 4 spaceset ts=4set expandtabset autoindentset showmatch" allow backspacing over everything in insert modeset backspace=indent,eol,startset background=dark" set font" set guifont=DejaVu\ Sans\ Mono\ 15set guifont=Courier\ 10\ Pitch\ 15" set curlineset cursorline"" set numberset number"hi clear hi Boolean guifg=#dca3a3 gui=boldhi Character guifg=#dca3a3 gui=boldhi Comment guifg=#7f7f7fhi Condtional guifg=#8fffffhi Constant guifg=#dca3a3 gui=boldhi Cursor guifg=#000000 guibg=#aeaeaehi Debug guifg=#dca3a3 gui=boldhi Define guifg=#ffcfaf gui=boldhi Delimiter guifg=#8f8f8fhi DiffAdd guibg=#613c46hi DiffChange guibg=#333333hi DiffDelete guifg=#333333 guibg=#464646 gui=nonehi DiffText guifg=#ffffff guibg=#1f1f1f gui=boldhi Directory guifg=#ffffff gui=boldhi Error guifg=#000000 guibg=#00ffffhi ErrorMsg guifg=#000000 guibg=#00c0cfhi Exception guifg=#8fffff gui=underlinehi Float guifg=#9c93b3hi FoldColumn guifg=#dca3a3 guibg=#464646hi Folded guifg=#dca3a3 guibg=#333333hi Function guifg=#ffff8fhi Identifier guifg=#ffffffhi Include guifg=#ffcfaf gui=boldhi IncSearch guifg=#000000 guibg=#c15c66hi Keyword guifg=#ffffff gui=boldhi Label guifg=#8fffff gui=underlinehi LineNr guifg=#7f7f7f guibg=#464646hi Macro guifg=#ffcfaf gui=boldhi ModeMsg guifg=#dca3a3 gui=boldhi MoreMsg guifg=#ffffff gui=boldhi NonText guifg=#1f1f1fhi Normal guifg=#cccccc guibg=#3f3f3fhi Number guifg=#aca0a3hi Operator guifg=#ffffffhi PreCondit guifg=#dfaf8f gui=boldhi PreProc guifg=#ffcfaf gui=boldhi Question guifg=#ffffff gui=boldhi Repeat guifg=#8fffff gui=underlinehi Search guifg=#000000 guibg=#c15c66hi SpecialChar guifg=#dca3a3 gui=boldhi SpecialComment guifg=#dca3a3 gui=boldhi Special guifg=#7f7f7fhi SpecialKey guifg=#7e7e7ehi Statement guifg=#8fffffhi StatusLine guifg=#333333 guibg=#f18c96hi StatusLineNC guifg=#333333 guibg=#cccccchi StorageClass guifg=#ffffff gui=boldhi String guifg=#cc9393hi Structure guifg=#ffffff gui=bold,underlinehi Tag guifg=#dca3a3 gui=boldhi Title guifg=#ffffff guibg=#333333 gui=boldhi Todo guifg=#ffffff guibg=#000000 gui=boldhi Typedef guifg=#ffffff gui=bold,underlinehi Type guifg=#ffffff gui=boldhi VertSplit guifg=#333333 guibg=#cccccchi Visual guifg=#333333 guibg=#f18c96 gui=reversehi VisualNOS guifg=#333333 guibg=#f18c96 gui=bold,underlinehi WarningMsg guifg=#ffffff guibg=#333333 gui=boldhi WildMenu guifg=#000000 guibg=#dca3a3if has("vms") set nobackup" do not keep a backup file, use versions insteadelse set backup" keep a backup fileendifset history=50" keep 50 lines of command line historyset ruler" show the cursor position all the timeset showcmd" display incomplete commandsset 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 formattingmap 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=aendif" 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 hlsearchendif" 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 ENDelse set autoindent" always set autoindenting onendif " 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 | diffthisendif
Linux:
在以上的基础上添加了文件目录NERDtree,c/c++程序的一键编译。
" An example for a vimrc file."" Maintainer:Bram Moolenaar <Bram@vim.org>" Last change:2008 Dec 17"" 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" finishendif" Use Vim settings, rather than Vi settings (much better!)." This must be first, because it changes other options as a side effect.set nocompatible" Make Tab 4 spaceset ts=4set expandtabset autoindent"set showmatch" allow backspacing over everything in insert modeset backspace=indent,eol,startset background=dark" set font" set guifont=DejaVu\ Sans\ Mono\ 15 set guifont=Courier\ 10\ Pitch\ 12" set curlineset cursorline"" set numberset number" set fileonfiletype on" 打开折叠map <F3> zO" 关闭折叠 map <F4> zc" 打开所有折叠map <F5> zR" 关闭所有折叠map <F6> zM"hi clear hi Boolean guifg=#dca3a3 gui=boldhi Character guifg=#dca3a3 gui=boldhi Comment guifg=#7f7f7fhi Condtional guifg=#8fffffhi Constant guifg=#dca3a3 gui=boldhi Cursor guifg=#000000 guibg=#aeaeaehi Debug guifg=#dca3a3 gui=boldhi Define guifg=#ffcfaf gui=boldhi Delimiter guifg=#8f8f8fhi DiffAdd guibg=#613c46hi DiffChange guibg=#333333hi DiffDelete guifg=#333333 guibg=#464646 gui=nonehi DiffText guifg=#ffffff guibg=#1f1f1f gui=boldhi Directory guifg=#ffffff gui=boldhi Error guifg=#000000 guibg=#00ffffhi ErrorMsg guifg=#000000 guibg=#00c0cfhi Exception guifg=#8fffff gui=underlinehi Float guifg=#9c93b3hi FoldColumn guifg=#dca3a3 guibg=#464646hi Folded guifg=#dca3a3 guibg=#333333hi Function guifg=#ffff8fhi Identifier guifg=#ffffffhi Include guifg=#ffcfaf gui=boldhi IncSearch guifg=#000000 guibg=#c15c66hi Keyword guifg=#ffffff gui=boldhi Label guifg=#8fffff gui=underlinehi LineNr guifg=#7f7f7f guibg=#464646hi Macro guifg=#ffcfaf gui=boldhi ModeMsg guifg=#dca3a3 gui=boldhi MoreMsg guifg=#ffffff gui=boldhi NonText guifg=#1f1f1fhi Normal guifg=#cccccc guibg=#3f3f3fhi Number guifg=#aca0a3hi Operator guifg=#ffffffhi PreCondit guifg=#dfaf8f gui=boldhi PreProc guifg=#ffcfaf gui=boldhi Question guifg=#ffffff gui=boldhi Repeat guifg=#8fffff gui=underlinehi Search guifg=#000000 guibg=#c15c66hi SpecialChar guifg=#dca3a3 gui=boldhi SpecialComment guifg=#dca3a3 gui=boldhi Special guifg=#7f7f7fhi SpecialKey guifg=#7e7e7ehi Statement guifg=#8fffffhi StatusLine guifg=#333333 guibg=#f18c96hi StatusLineNC guifg=#333333 guibg=#cccccchi StorageClass guifg=#ffffff gui=boldhi String guifg=#cc9393hi Structure guifg=#ffffff gui=bold,underlinehi Tag guifg=#dca3a3 gui=boldhi Title guifg=#ffffff guibg=#333333 gui=boldhi Todo guifg=#ffffff guibg=#000000 gui=boldhi Typedef guifg=#ffffff gui=bold,underlinehi Type guifg=#ffffff gui=boldhi VertSplit guifg=#333333 guibg=#cccccchi Visual guifg=#333333 guibg=#f18c96 gui=reversehi VisualNOS guifg=#333333 guibg=#f18c96 gui=bold,underlinehi WarningMsg guifg=#ffffff guibg=#333333 gui=boldhi WildMenu guifg=#000000 guibg=#dca3a3if has("vms") set nobackup" do not keep a backup file, use versions insteadelse set backup" keep a backup fileendifset history=50" keep 50 lines of command line historyset ruler" show the cursor position all the timeset showcmd" display incomplete commandsset 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 formattingmap 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=aendif" 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 hlsearchendif" 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 ENDelse set autoindent" always set autoindenting onendif " 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 | diffthisendif" NERDtree"" How can I open a NERDTree automatically when vim starts up?"" autocmd vimenter * NERDTree" How can I open a NERDTree automatically when vim starts up if no files were specified?autocmd vimenter * if !argc() | NERDTree | endifset autochdirautocmd BufEnter * silent! lcd %:p:h" Using the autocmd method, you could customize when the directory change takes place. For example, to not change directory if the file is in /tmp:autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif" 初始位置,初始大小winpos 100 100 set lines=25 columns=108"------------------------------------------------------------------------------" < 判断操作系统是否是 Windows 还是 Linux >"------------------------------------------------------------------------------if(has("win32") || has("win64") || has("win95") || has("win16")) let g:iswindows = 1else let g:iswindows = 0endif" auto compiler"------------------------------------------------------------------------------" < 判断是终端还是 Gvim >"------------------------------------------------------------------------------if has("gui_running") let g:isGUI = 1else let g:isGUI = 0endif"------------------------------------------------------------------------------" < 编译、连接、运行配置 >"------------------------------------------------------------------------------" F9 一键保存、编译、连接存并运行map <F9> :call Run()<CR>imap <F9> <ESC>:call Run()<CR>" Ctrl + F9 一键保存并编译map <c-F9> :call Compile()<CR>imap <c-F9> <ESC>:call Compile()<CR>" Ctrl + F10 一键保存并连接map <c-F10> :call Link()<CR>imap <c-F10> <ESC>:call Link()<CR>let s:LastShellReturn_C = 0let s:LastShellReturn_L = 0let s:ShowWarning = 1let s:Obj_Extension = '.o'let s:Exe_Extension = '.exe'let s:Sou_Error = 0let s:windows_CFlags = 'gcc\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'let s:linux_CFlags = 'gcc\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'let s:windows_CPPFlags = 'g++\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'let s:linux_CPPFlags = 'g++\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'func! Compile() exe ":ccl" exe ":update" if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx" let s:Sou_Error = 0 let s:LastShellReturn_C = 0 let Sou = expand("%:p") let Obj = expand("%:p:r").s:Obj_Extension let Obj_Name = expand("%:p:t:r").s:Obj_Extension let v:statusmsg = '' if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) redraw! if expand("%:e") == "c" if g:iswindows exe ":setlocal makeprg=".s:windows_CFlags else exe ":setlocal makeprg=".s:linux_CFlags endif echohl WarningMsg | echo " compiling..." silent make elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" if g:iswindows exe ":setlocal makeprg=".s:windows_CPPFlags else exe ":setlocal makeprg=".s:linux_CPPFlags endif echohl WarningMsg | echo " compiling..." silent make endif redraw! if v:shell_error != 0 let s:LastShellReturn_C = v:shell_error endif if g:iswindows if s:LastShellReturn_C != 0 exe ":bo cope" echohl WarningMsg | echo " compilation failed" else if s:ShowWarning exe ":bo cw" endif echohl WarningMsg | echo " compilation successful" endif else if empty(v:statusmsg) echohl WarningMsg | echo " compilation successful" else exe ":bo cope" endif endif else echohl WarningMsg | echo ""Obj_Name"is up to date" endif else let s:Sou_Error = 1 echohl WarningMsg | echo " please choose the correct source file" endif exe ":setlocal makeprg=make"endfuncfunc! Link() call Compile() if s:Sou_Error || s:LastShellReturn_C != 0 return endif let s:LastShellReturn_L = 0 let Sou = expand("%:p") let Obj = expand("%:p:r").s:Obj_Extension if g:iswindows let Exe = expand("%:p:r").s:Exe_Extension let Exe_Name = expand("%:p:t:r").s:Exe_Extension else let Exe = expand("%:p:r") let Exe_Name = expand("%:p:t:r") endif let v:statusmsg = ''if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) redraw! if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj)) if expand("%:e") == "c" setlocal makeprg=gcc\ -o\ %<\ %<.o echohl WarningMsg | echo " linking..." silent make elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" setlocal makeprg=g++\ -o\ %<\ %<.o echohl WarningMsg | echo " linking..." silent make endif redraw! if v:shell_error != 0 let s:LastShellReturn_L = v:shell_error endif if g:iswindows if s:LastShellReturn_L != 0 exe ":bo cope" echohl WarningMsg | echo " linking failed" else if s:ShowWarning exe ":bo cw" endif echohl WarningMsg | echo " linking successful" endif else if empty(v:statusmsg) echohl WarningMsg | echo " linking successful" else exe ":bo cope" endif endif else echohl WarningMsg | echo ""Exe_Name"is up to date" endif endif setlocal makeprg=makeendfuncfunc! Run() let s:ShowWarning = 0 call Link() let s:ShowWarning = 1 if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0 return endif let Sou = expand("%:p") let Obj = expand("%:p:r").s:Obj_Extension if g:iswindows let Exe = expand("%:p:r").s:Exe_Extension else let Exe = expand("%:p:r") endif if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) redraw! echohl WarningMsg | echo " running..." if g:iswindows exe ":!%<.exe" else if g:isGUI exe ":!gnome-terminal -e ./%<" else exe ":!./%<" endif endif redraw! echohl WarningMsg | echo " running finish" endifendfunc
2014.5.28:
增加了C缩进,另外如果需要NERDtree需要另外下载;
" An example for a vimrc file."" Maintainer:Bram Moolenaar <Bram@vim.org>" Last change:2008 Dec 17"" 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" finishendif" Use Vim settings, rather than Vi settings (much better!)." This must be first, because it changes other options as a side effect.set nocompatible"""" Make Tab 4 spaceset ts=4set expandtabset autoindentset softtabstop=4set shiftwidth=4set cindentset cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s"""""set showmatch" allow backspacing over everything in insert modeset backspace=indent,eol,startset background=dark" set font" set guifont=DejaVu\ Sans\ Mono\ 15 set guifont=Courier\ 10\ Pitch\ 12" set curlineset cursorline"" set numberset number" set fileonfiletype on" 打开折叠map <F3> zO" 关闭折叠 map <F4> zc" 打开所有折叠map <F5> zR" 关闭所有折叠map <F6> zM"hi clear hi Boolean guifg=#dca3a3 gui=boldhi Character guifg=#dca3a3 gui=boldhi Comment guifg=#7f7f7fhi Condtional guifg=#8fffffhi Constant guifg=#dca3a3 gui=boldhi Cursor guifg=#000000 guibg=#aeaeaehi Debug guifg=#dca3a3 gui=boldhi Define guifg=#ffcfaf gui=boldhi Delimiter guifg=#8f8f8fhi DiffAdd guibg=#613c46hi DiffChange guibg=#333333hi DiffDelete guifg=#333333 guibg=#464646 gui=nonehi DiffText guifg=#ffffff guibg=#1f1f1f gui=boldhi Directory guifg=#ffffff gui=boldhi Error guifg=#000000 guibg=#00ffffhi ErrorMsg guifg=#000000 guibg=#00c0cfhi Exception guifg=#8fffff gui=underlinehi Float guifg=#9c93b3hi FoldColumn guifg=#dca3a3 guibg=#464646hi Folded guifg=#dca3a3 guibg=#333333hi Function guifg=#ffff8fhi Identifier guifg=#ffffffhi Include guifg=#ffcfaf gui=boldhi IncSearch guifg=#000000 guibg=#c15c66hi Keyword guifg=#ffffff gui=boldhi Label guifg=#8fffff gui=underlinehi LineNr guifg=#7f7f7f guibg=#464646hi Macro guifg=#ffcfaf gui=boldhi ModeMsg guifg=#dca3a3 gui=boldhi MoreMsg guifg=#ffffff gui=boldhi NonText guifg=#1f1f1fhi Normal guifg=#cccccc guibg=#3f3f3fhi Number guifg=#aca0a3hi Operator guifg=#ffffffhi PreCondit guifg=#dfaf8f gui=boldhi PreProc guifg=#ffcfaf gui=boldhi Question guifg=#ffffff gui=boldhi Repeat guifg=#8fffff gui=underlinehi Search guifg=#000000 guibg=#c15c66hi SpecialChar guifg=#dca3a3 gui=boldhi SpecialComment guifg=#dca3a3 gui=boldhi Special guifg=#7f7f7fhi SpecialKey guifg=#7e7e7ehi Statement guifg=#8fffffhi StatusLine guifg=#333333 guibg=#f18c96hi StatusLineNC guifg=#333333 guibg=#cccccchi StorageClass guifg=#ffffff gui=boldhi String guifg=#cc9393hi Structure guifg=#ffffff gui=bold,underlinehi Tag guifg=#dca3a3 gui=boldhi Title guifg=#ffffff guibg=#333333 gui=boldhi Todo guifg=#ffffff guibg=#000000 gui=boldhi Typedef guifg=#ffffff gui=bold,underlinehi Type guifg=#ffffff gui=boldhi VertSplit guifg=#333333 guibg=#cccccchi Visual guifg=#333333 guibg=#f18c96 gui=reversehi VisualNOS guifg=#333333 guibg=#f18c96 gui=bold,underlinehi WarningMsg guifg=#ffffff guibg=#333333 gui=boldhi WildMenu guifg=#000000 guibg=#dca3a3if has("vms") set nobackup" do not keep a backup file, use versions insteadelse set backup" keep a backup fileendifset history=50" keep 50 lines of command line historyset ruler" show the cursor position all the timeset showcmd" display incomplete commandsset 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 formattingmap 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=aendif" 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 hlsearchendif" 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 ENDelse set autoindent" always set autoindenting onendif " 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 | diffthisendif" NERDtree"" How can I open a NERDTree automatically when vim starts up?"" autocmd vimenter * NERDTree" How can I open a NERDTree automatically when vim starts up if no files were specified?autocmd vimenter * if !argc() | NERDTree | endifset autochdirautocmd BufEnter * silent! lcd %:p:h" Using the autocmd method, you could customize when the directory change takes place. For example, to not change directory if the file is in /tmp:autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif" 初始位置,初始大小winpos 100 100 set lines=25 columns=108"------------------------------------------------------------------------------" < 判断操作系统是否是 Windows 还是 Linux >"------------------------------------------------------------------------------if(has("win32") || has("win64") || has("win95") || has("win16")) let g:iswindows = 1else let g:iswindows = 0endif" auto compiler"------------------------------------------------------------------------------" < 判断是终端还是 Gvim >"------------------------------------------------------------------------------if has("gui_running") let g:isGUI = 1else let g:isGUI = 0endif"------------------------------------------------------------------------------" < 编译、连接、运行配置 >"------------------------------------------------------------------------------" F9 一键保存、编译、连接存并运行map <F9> :call Run()<CR>imap <F9> <ESC>:call Run()<CR>" Ctrl + F9 一键保存并编译map <c-F9> :call Compile()<CR>imap <c-F9> <ESC>:call Compile()<CR>" Ctrl + F10 一键保存并连接map <c-F10> :call Link()<CR>imap <c-F10> <ESC>:call Link()<CR>let s:LastShellReturn_C = 0let s:LastShellReturn_L = 0let s:ShowWarning = 1let s:Obj_Extension = '.o'let s:Exe_Extension = '.exe'let s:Sou_Error = 0let s:windows_CFlags = 'gcc\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'let s:linux_CFlags = 'gcc\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'let s:windows_CPPFlags = 'g++\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'let s:linux_CPPFlags = 'g++\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'func! Compile() exe ":ccl" exe ":update" if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx" let s:Sou_Error = 0 let s:LastShellReturn_C = 0 let Sou = expand("%:p") let Obj = expand("%:p:r").s:Obj_Extension let Obj_Name = expand("%:p:t:r").s:Obj_Extension let v:statusmsg = '' if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) redraw! if expand("%:e") == "c" if g:iswindows exe ":setlocal makeprg=".s:windows_CFlags else exe ":setlocal makeprg=".s:linux_CFlags endif echohl WarningMsg | echo " compiling..." silent make elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" if g:iswindows exe ":setlocal makeprg=".s:windows_CPPFlags else exe ":setlocal makeprg=".s:linux_CPPFlags endif echohl WarningMsg | echo " compiling..." silent make endif redraw! if v:shell_error != 0 let s:LastShellReturn_C = v:shell_error endif if g:iswindows if s:LastShellReturn_C != 0 exe ":bo cope" echohl WarningMsg | echo " compilation failed" else if s:ShowWarning exe ":bo cw" endif echohl WarningMsg | echo " compilation successful" endif else if empty(v:statusmsg) echohl WarningMsg | echo " compilation successful" else exe ":bo cope" endif endif else echohl WarningMsg | echo ""Obj_Name"is up to date" endif else let s:Sou_Error = 1 echohl WarningMsg | echo " please choose the correct source file" endif exe ":setlocal makeprg=make"endfuncfunc! Link() call Compile() if s:Sou_Error || s:LastShellReturn_C != 0 return endif let s:LastShellReturn_L = 0 let Sou = expand("%:p") let Obj = expand("%:p:r").s:Obj_Extension if g:iswindows let Exe = expand("%:p:r").s:Exe_Extension let Exe_Name = expand("%:p:t:r").s:Exe_Extension else let Exe = expand("%:p:r") let Exe_Name = expand("%:p:t:r") endif let v:statusmsg = ''if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) redraw! if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj)) if expand("%:e") == "c" setlocal makeprg=gcc\ -o\ %<\ %<.o echohl WarningMsg | echo " linking..." silent make elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" setlocal makeprg=g++\ -o\ %<\ %<.o echohl WarningMsg | echo " linking..." silent make endif redraw! if v:shell_error != 0 let s:LastShellReturn_L = v:shell_error endif if g:iswindows if s:LastShellReturn_L != 0 exe ":bo cope" echohl WarningMsg | echo " linking failed" else if s:ShowWarning exe ":bo cw" endif echohl WarningMsg | echo " linking successful" endif else if empty(v:statusmsg) echohl WarningMsg | echo " linking successful" else exe ":bo cope" endif endif else echohl WarningMsg | echo ""Exe_Name"is up to date" endif endif setlocal makeprg=makeendfuncfunc! Run() let s:ShowWarning = 0 call Link() let s:ShowWarning = 1 if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0 return endif let Sou = expand("%:p") let Obj = expand("%:p:r").s:Obj_Extension if g:iswindows let Exe = expand("%:p:r").s:Exe_Extension else let Exe = expand("%:p:r") endif if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) redraw! echohl WarningMsg | echo " running..." if g:iswindows exe ":!%<.exe" else if g:isGUI exe ":!gnome-terminal -e ./%<" else exe ":!./%<" endif endif redraw! echohl WarningMsg | echo " running finish" endifendfunc
0 0
- 我的vimrc
- 我的vimrc设置
- 我的vimrc
- 我的.vimrc
- 我的 .vimrc 配置
- 我的 .vimrc
- VIM:我的vimrc
- 我的 .vimrc
- 我的vimrc
- 我的.vimrc文件
- 我的.vimrc
- 我的.vimrc
- 我用的vimrc
- 我的vimrc
- 我的vimrc
- 我的vimrc
- 我的.vimrc
- 【Vim】:我的vimrc
- java中equals()方法应该具有的特性
- TI C66x DSP 四种内存保护问题 -之- 针对CPU访问外存(DDR3 or MSM)时的内存保护问题
- 报ORA-00845:MEMORY_TARGET not supported on this system故障解决
- Java中static成员的用法
- Python基础编程(一)基础知识
- 我的Vimrc
- VMware下Ubuntu与宿主Windows共享文件夹
- COCOS2D-X 3.0 文字按钮 不显示 或者闪动
- intellij中Compile、Make和Build的区别
- C语言 strtok函数使用
- 真正的成功(约翰·伍登)
- 在linux下配置tftp服务器和nfs服务器
- 练习1-4
- MySQ命令行L常用命令