~~~
"""""""""""""""""
" => 全局配置 "
"""""""""""""""""
" 关闭兼容模式
set nocompatiblejava
" 设置历史记录步数
set history=1024bash
" 开启文件类型检测
filetype on
filetype plugin on
filetype indent on工具
" 文件在外部修改时,自动更新该文件
set autoread字体
" 激活鼠标功能
set mouse=aui
"""""""""""""""""""
" => 字体和颜色 "
"""""""""""""""""""
" 开启语法
syntax enable编码
" 设置配色
colorscheme desertspa
" 高亮显示当前行
set cursorline
hi cursorline guibg=#00ff00
hi CursorColumn guibg=#00ff00命令行
""""""""""""""""
" =>代码折叠 "
""""""""""""""""
" 开启代码折叠
set foldenableorm
" 配置代码折叠方式
set foldmethod=manual继承
" 设置折叠区域宽度
set foldcolumn=0
" 设置折叠层数为3
setlocal foldlevel=3
" 设置为自动关闭折叠
set foldclose=all
" 用空格键代替zo和zc快捷键实现开关折叠
nnoremap
"""""""""""""""""
" => 文字处理 "
"""""""""""""""""
" 使用空格替换Tab
set expandtab
" 设置全部Tab和缩进为4个空格
set tabstop=4
" 设定 << 和 >> 命令移动时的宽度为4
set shiftwidth=4
" 按退格键时一次删掉4个空格
set softtabstop=4
set smarttab
" 缩进,自动缩进(继承前一行的缩进)
set ai
" 智能缩进
set si
" 自动换行
set wrap
" 设置软宽度
set sw=4
""""""""""""""""
" =>Vim 界面 "
""""""""""""""""
" Turn on WiLd menu
set wildmenu
" 设置标尺
set ruler
" 设置命令行高度
set cmdheight=1
" 显示行数
set number
" Do not redraw, when running macros.. lazyredraw
set lz
" 设置退格
set backspace=eol,start,indent
" Backspace and cursor keys wrap to
set whichwrap+=<,>,h,l
" Set magic on (设置魔术)
set magic
" 关闭遇到错误时的声音提示
" 关闭错误信息响铃
set noerrorbells
" 关闭使用可视响铃代替呼叫
set novisualbell
" 显示匹配的括号([{ 和 }])
set showmatch
" How many tenths of a second to blink
set mat=2
" 搜索时高亮显示匹配到的内容
set hlsearch
"""""""""""""""""
" => 编码设置 "
"""""""""""""""""
" 设置编码
set encoding=utf-8
"设置文件编码
set fileencoding=utf-8
" 设置终端编码
set termencoding=utf-8
"""""""""""""""""
" => 其余设置 "
"""""""""""""""""
" 开启新行时使用智能自动缩进
set smartindent
set cin
set showmatch
" 隐藏工具栏
set guioptions-=T
" 隐藏菜单栏
set guioptions-=m
" 置空错误铃声的终端代码
set vb t_vb=
" 显示状态栏(默认值为1,表示没法显示状态栏)
set laststatus=2
" 粘贴不换行问题的解决方法
set pastetoggle=
" 设置背景色
set background=dark
" 设置高亮相关
highlight Search ctermbg=black ctermfg=white guifg=white guibg=black
"hi CursorLine cterm=NONE ctermbg=black ctermfg=white guibg=black guifg=white
" 在Shell脚本开头自动增长解释器及做者等版权信息
autocmd BufNewFile .py,.cc,.sh,.java exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1, "#!/bin/bash")
call setline(2, "##############################################")
call setline(3, "#File Name: ".expand("%"))
call setline(4, "#Version: V1.0")
call setline(5, "#Author: ")
call setline(6, "#Created Time: ".strftime("%F %T"))
call setline(7, "#Description: ")
call setline(8, "##############################################")
call setline(9, "")
endif
endfunc
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
" 设置() [] {} ''自动补齐
inoremap ( ()
inoremap [ []
inoremap { {}
inoremap ' ''
" 显示Tab和空格
set list
" 设置Tab和空格样式
set lcs=tab:|\ ,nbsp:%,trail:-
" 设定活动行样式
"highlight LeaderTab guifg=#666666
"highlight Comment ctermfg=green guifg=green
"hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
"hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
~~~