vim 配置文件

vim 配置文件位置

 /etc/vim/vimrc

常用设置

" 使用方法:在/etc/vim/vimrc中添加下面设置即可

set nocompatible "不要vim模仿vi模式,建议设置,否则会有很多不兼容的问题 set number set tabstop=4 " 设定 tab 长度为 4 set softtabstop=4 set shiftwidth=4 " 设置缩进的空格数为4 colorscheme desert " 设定配色方案 syntax on " 自动语法高亮 set history=1000 " 设置历史行数 set magic " 设置魔术 "set showmatch " 设置括号匹配模式 set cindent " 开启新行时使用智能自动缩进 set clipboard+=unnamed " 与windows共享剪贴板 set autoindent " 自动对齐 set hlsearch " 搜索时高亮显示被找到的文本 filetype plugin indent on " 开启插件 set incsearch " 输入搜索内容时就显示搜索结果 "set foldenable " 开始折叠 "set foldmethod=syntax " 设置语法折叠 "set foldcolumn=0 " 设置折叠区域的宽度 "setlocal foldlevel=1 " 设置折叠层数为 " set foldclose=all " 设置为自动关闭折叠 " nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠

整个配置文件

" 此代码为vim整个配置文件,可以复制后保存为vimrc,替换/etc/vim/vimrc
" 替换命令(第一条指令为备份原有vim配置,第二条为覆盖vim配置文件):
" sudo cp /etc/vim/vimrc /etc/vim/vimrc_backup
" sudo cp vimrc /etc/vim
" 注意:当前工作路径应该和你保存的vimrc一致
if
(has("win32") || has("win95") || has("win64") || has("win16")) "判定当前操作系统类型 let g:iswindows=1 else let g:iswindows=0 endif set nocompatible "不要vim模仿vi模式,建议设置,否则会有很多不兼容的问题 set number set tabstop=4 " 设定 tab 长度为 4 set softtabstop=4 set shiftwidth=4 " 设置缩进的空格数为4 colorscheme desert " 设定配色方案 syntax on " 自动语法高亮 set history=1000 " 设置历史行数 set magic " 设置魔术 "set showmatch " 设置括号匹配模式 set cindent " 开启新行时使用智能自动缩进 set clipboard+=unnamed " 与windows共享剪贴板 set autoindent " 自动对齐 set hlsearch " 搜索时高亮显示被找到的文本 filetype plugin indent on " 开启插件 set incsearch " 输入搜索内容时就显示搜索结果 "set foldenable " 开始折叠 "set foldmethod=syntax " 设置语法折叠 "set foldcolumn=0 " 设置折叠区域的宽度 "setlocal foldlevel=1 " 设置折叠层数为 " set foldclose=all " 设置为自动关闭折叠 " nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠 "进行版权声明的设置 "添加或更新头 map <F4> :call TitleDet()<cr>'s "map <F4> :call AddTitle()<CR>'s function AddTitle() call append(0 , "/****************************************************") call append(1 ,"Author: the Sun ") call append(2 ,"Email: 907238952@qq.com") call append(3 ,"Last modified: ".strftime("%Y-%m-%d %H:%M:%S")) call append(4 ,"Filename: ".expand("%:t")) call append(5 ,"*****************************************************/") echohl WarningMsg | echo "Successful in adding the copyright." | echohl None endf "更新最近修改时间和文件名 function UpdateTitle() normal m' execute '/Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M:%S")@' normal '' normal mk execute '/Filename:/s@:.*$@\=":\t\t".expand("%:t")@' execute "noh" normal 'k echohl WarningMsg | echo "Successful in updating the copy right." | echohl None endfunction "判断前10行代码里面,是否有Last modified这个单词, "如果没有的话,代表没有添加过作者信息,需要新添加; "如果有的话,那么只需要更新即可 function TitleDet() let n=1 "默认为添加 while n < 6 let line = getline(n) if line =~ '^\S*Last\smodified:\S*.*$' call UpdateTitle() return endif let n = n + 1 endwhile call AddTitle() endfunction "定义<F5>为运行的快捷键 map <F5> :call CompileRun()<CR> func CompileRun() exec "w" "C程序 if &filetype == 'c' exec "!gcc % -o %<" exec "! ./%<" exec ":q" elseif &filetype == 'cpp' exec "!g++ % -o %<" exec "! ./%<" exec ":q" endif endfunc "*************************************************************************** "华丽的分割线 "*************************************************************************** " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by " the call to :runtime you can find below. If you wish to change any of those " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim " will be overwritten everytime an upgrade of the vim packages is performed. " It is recommended to make changes after sourcing debian.vim since it alters " the value of the 'compatible' option. " This line should not be removed as it ensures that various options are " properly set to work with the Vim-related packages available in Debian. runtime! debian.vim " Uncomment the next line to make Vim more Vi-compatible " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous " options, so any other options should be set AFTER setting 'compatible'. "set compatible " Vim5 and later versions support syntax highlighting. Uncommenting the next " line enables syntax highlighting by default. if has("syntax") syntax on endif " If using a dark background within the editing area and syntax highlighting " turn on this option as well "set background=dark " Uncomment the following to have Vim jump to the last position when " reopening a file "if has("autocmd") " au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif "endif " Uncomment the following to have Vim load indentation rules and plugins " according to the detected filetype. "if has("autocmd") " filetype plugin indent on "endif

 

posted @ 2015-06-19 15:07  bovenson  阅读(497)  评论(0编辑  收藏  举报