VIM 配置
說明
下面是vim 神器的一些個設置和配置,基本原則是盡量少用插件安裝,安裝插件具有簡單復制性,online特性。(如有時間可以寫個一鍵安裝腳本)
基礎配置
Mac 自帶的是vi,如未安裝Vim,可以使用homebrew 安裝:brew install vim
配置文件在用戶目錄下~/.vimrc,如果沒有,就自己創(chuàng)建一個。
內容如下:
"顯示行號
set number
"顯示標尺
set ruler
"歷史紀錄
set history=1000
"輸入的命令顯示出來,看的清楚些
set showcmd
"狀態(tài)行顯示的內容
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
"啟動顯示狀態(tài)行1,總是顯示狀態(tài)行2
set laststatus=2
"語法高亮顯示
syntax on
set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
set fileencoding=utf-8
set termencoding=utf-8
set fileformat=unix
set encoding=utf-8
"配色方案
colorscheme desert
"指定配色方案是256色
set t_Co=256
set wildmenu
"去掉有關vi一致性模式,避免以前版本的一些bug和局限,解決backspace不能使用的問題
set nocompatible
set backspace=indent,eol,start
set backspace=2
"啟用自動對齊功能,把上一行的對齊格式應用到下一行
set autoindent
"依據上面的格式,智能的選擇對齊方式,對于類似C語言編寫很有用處
set smartindent
"vim禁用自動備份
set nobackup
set nowritebackup
set noswapfile
"用空格代替tab
set expandtab
"設置顯示制表符的空格字符個數,改進tab縮進值,默認為8,現改為4
set tabstop=4
"統(tǒng)一縮進為4,方便在開啟了et后使用退格(backspace)鍵,每次退格將刪除X個空格
set softtabstop=4
"設定自動縮進為4個字符,程序中自動縮進所使用的空白長度
set shiftwidth=4
"設置幫助文件為中文(需要安裝vimcdoc文檔)
set helplang=cn
"顯示匹配的括號
set showmatch
"文件縮進及tab個數
au FileType html,python,vim,javascript setl shiftwidth=4
au FileType html,python,vim,javascript setl tabstop=4
au FileType java,php setl shiftwidth=4
au FileType java,php setl tabstop=4
"高亮搜索的字符串
set hlsearch
"檢測文件的類型
filetype on
filetype plugin on
filetype indent on
"C風格縮進
set cindent
set completeopt=longest,menu
"功能設置
"去掉輸入錯誤提示聲音
set noeb
"自動保存
set autowrite
"突出顯示當前行
set cursorline
"突出顯示當前列
set cursorcolumn
"設置光標樣式為豎線vertical bar
"Change cursor shape between insert and normal mode in iTerm2.app
"if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7""Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7""Block in normal mode
"endif
"共享剪貼板
set clipboard+=unnamed
"文件被改動時自動載入
set autoread
"頂部底部保持3行距離
set scrolloff=3
如果需要安裝相關插件請自行百度搜索vim插件.