set nocompatible "VIM IMPROVED模式,不相容舊VI
set mouse=a "開啟滑鼠功能 ssh遠端狀態下就不行了(應該是這樣吧?)
set background=dark "設定背景為暗,有些colorscheme需要
filetype plugin indent on "檔案類型 讓 插件可辨認 縮排 開啟
set encoding=utf-8 "大概就是設定為UTF8吧
set fileencodings=utf-8
syntax enable "編輯cpp,sh,php的時候會依語法以顏色區分
set t_Co=256 "明確的告知vim這是256色的終端機
set ruler "右下角狀態列顯示行號列號(通常配合set laststatus=2)
set laststatus=2 "永遠顯示畫面底下倒數第二行狀態列
set number "畫面左邊每一行開頭 顯示行號(我比較喜歡看右下角,這我都不開)
set autoindent "自動縮排
set nowrap "不要自動折行
set tabstop=2 "一個tab=兩個space
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set smarttab " 這是什麼?
set softtabstop=2 "這是什麼?
set list " 顯示看不見的字元 像是TAB或是行尾的空白
set backspace=indent,eol,start " backspace through everything ,像是縮行的空白,行尾的換行
set showcmd "讓你下命令時不用瞎子摸象,可以知道自己打到哪了
set showmode "在狀態列顯示目前VI模式
set gcr=a:blinkon0 "游標不要一閃一閃
set visualbell "不要發出聲音,改為螢幕閃光
set autoread "檔案被外部程式(例如筆記本)更改時VIM會自動RELOAD
set cursorline "光標所在的行 設為高亮
set hidden "這個有點硬派,VIM的男子漢在用的,意思是開的所有BUFFER都是隱藏的
"要配合:ls :b [n]來用
" List chars 這段主要是一些顯示上的小修改,例如TAB跟空白的顯示,行尾的空白,不折行時超出畫面的顯示
set listchars="" " Reset the listchars
set listchars=tab:\ \ " a tab should display as " ", trailing whitespace as "."
set listchars+=trail:. " show trailing spaces as dots
set listchars+=extends:> " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set listchars+=precedes:< " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set ignorecase " 搜尋的時候忽略大小寫
set smartcase " 承接上一句,除非你的搜尋理有一個以上的大寫字母
"====底下這邊是告訴VIM哪些檔案可以忽略 nerdtree時好用
" Disable output and VCS files 編譯出來的.o,版本控制之類的
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Disable archive files 壓縮檔直接忽略
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Disable music files 音樂
set wildignore+=*.mp3,*.mp4,*.m4a,*.m4r
" Disable pictures 照片
set wildignore+=*.png,*.jpg,*.jpeg,*.gif,*.bmp,*.svg
" Ignore bundler and sass cache 這是Ruby on Rails的,沒用就忽略吧
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Disable temp and backup files VIM自己的.swp
set wildignore+=*.swp,*~,._*
"" Backup and swap files 這應該不難理解
set backupdir^=~/.vim/_backup// " where to put backup files.
set directory^=~/.vim/_temp// " where to put swap files.發表人:
x13 時間: 2013-3-9 12:08 PM
" upper/lower first char of word
nmap <leader>U mQgewvU`Q "\U 游標所在字 字首轉大寫
nmap <leader>L mQgewvu`Q "\L 游標所在字 字首轉小寫
" cd to the directory containing the file in the buffer
nmap <silent> <leader>cd :lcd %:h<CR> "\cd 映射到 :lcd 目前檔案buffer所在目錄
" Underline the current line with '='
nmap <silent> <leader>ul :t.<CR>Vr= "在上面一行的下面加上 =
"========================================== 像這樣 寫註解常用發表人:
x13 時間: 2013-3-9 12:10 PM
接著這個部分因為我常用OSX跟LINUX
所以一個功能寫兩次用if else 區分開
if has("gui_macvim") && has("gui_running")
" Map command-[ and command-] to indenting or outdenting
" while keeping the original selection in visual mode
vmap <D-]> >gv " ⌘ + ] 向後縮排
vmap <D-[> <gv " ⌘ + [ 向前縮排 以下都一樣模式不同而已