服务器上 vim 简单设置

" 不兼容
set nocompatible


" 显示行号
set number

" 不发出错误滴滴声
set noerrorbells

" 高亮显示匹配的括号
set showmatch

" 统一缩进为 2 个空格(可以在 editorconfig 更细控制)
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab

" 高亮搜索结果
set hlsearch

" 高亮第80列
set colorcolumn=80

" UTF8 编码
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8

" 不自动备份
set nobackup

" 高亮
syntax enable

" 主题
set t_Co=256
let g:rehash256=1

" no mouse
set mouse=

" paste mode toggle is F9
set pastetoggle=<f9>

" prepend python header
function HeaderPython()
    call setline(1, "#!/usr/bin/env python")
    call append(1, "# coding: utf-8")
    call append(2, "# [email protected]" . strftime('%Y/%m/%d', localtime()))
    normal G
    normal o
    normal o
endf
autocmd bufnewfile *.py call HeaderPython()

" 折叠
set foldmethod=marker
set foldnestmax=2
autocmd BufRead,BufNewFile *.py set foldmethod=indent foldlevel=99
" press space to fold/unfold code
nnoremap <space> za
vnoremap <space> zf

" 自动缩进
" set autoindent

" 无拼写检查
set spl=en spell
set nospell

set wildmenu
set wildmode=list:longest,full
set backspace=2
set showcmd
filetype plugin indent on


" Close Location List
nmap <F8> :lclose<CR>
imap <F8> <ESC>:lclose<CR>a