vim配置詳解

vim 配置文件 ,高亮+自動縮進(jìn)+行號+折疊+優(yōu)化

公司主營業(yè)務(wù):成都做網(wǎng)站、成都網(wǎng)站制作、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)建站是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)建站推出廣陽免費(fèi)做網(wǎng)站回饋大家。

 
將一下代碼copy到 用戶目錄下 新建文件為  .vimrc
保存即可生效; 如果想所有用戶生效 請修改 /etc/vimrc (建議先cp一份)
"=========================================================================
" DesCRiption: 適合自己使用的vimrc文件,for Linux/Windows, GUI/Console
"
" Last Change: 2010年08月02日 15時(shí)13分
"
" Version: 1.80
"
"=========================================================================

set nocompatible " 關(guān)閉 vi 兼容模式
syntax on " 自動語法高亮
colorscheme molokai " 設(shè)定配色方案
set number " 顯示行號
set cursorline " 突出顯示當(dāng)前行
set ruler " 打開狀態(tài)欄標(biāo)尺
set shiftwidth=4 " 設(shè)定 << 和 >> 命令移動時(shí)的寬度為 4
set softtabstop=4 " 使得按退格鍵時(shí)可以一次刪掉 4 個(gè)空格
set tabstop=4 " 設(shè)定 tab 長度為 4
set nobackup " 覆蓋文件時(shí)不備份
set autochdir " 自動切換當(dāng)前目錄為當(dāng)前文件所在的目錄
filetype plugin indent on " 開啟插件
set backupcopy=yes " 設(shè)置備份時(shí)的行為為覆蓋
set ignorecase smartcase " 搜索時(shí)忽略大小寫,但在有一個(gè)或以上大寫字母時(shí)仍保持對大小寫敏感
set nowrapscan " 禁止在搜索到文件兩端時(shí)重新搜索
set incsearch " 輸入搜索內(nèi)容時(shí)就顯示搜索結(jié)果
set hlsearch " 搜索時(shí)高亮顯示被找到的文本
set noerrorbells " 關(guān)閉錯(cuò)誤信息響鈴
set novisualbell " 關(guān)閉使用可視響鈴代替呼叫
set t_vb= " 置空錯(cuò)誤鈴聲的終端代碼
" set showmatch " 插入括號時(shí),短暫地跳轉(zhuǎn)到匹配的對應(yīng)括號
" set matchtime=2 " 短暫跳轉(zhuǎn)到匹配括號的時(shí)間
set magic " 設(shè)置魔術(shù)
set hidden " 允許在有未保存的修改時(shí)切換緩沖區(qū),此時(shí)的修改由 vim 負(fù)責(zé)保存
set guioptions-=T " 隱藏工具欄
set guioptions-=m " 隱藏菜單欄
set smartindent " 開啟新行時(shí)使用智能自動縮進(jìn)
set backspace=indent,eol,start
" 不設(shè)定在插入狀態(tài)無法用退格鍵和 Delete 鍵刪除回車符
set cmdheight=1 " 設(shè)定命令行的行數(shù)為 1
set laststatus=2 " 顯示狀態(tài)欄 (默認(rèn)值為 1, 無法顯示狀態(tài)欄)
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
" 設(shè)置在狀態(tài)行顯示的信息
set foldenable " 開始折疊
set foldmethod=syntax " 設(shè)置語法折疊
set foldcolumn=0 " 設(shè)置折疊區(qū)域的寬度
setlocal foldlevel=1 " 設(shè)置折疊層數(shù)為
" set foldclose=all " 設(shè)置為自動關(guān)閉折疊
" nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" 用空格鍵來開關(guān)折疊


" return OS type, eg: windows, or linux, mac, et.st..
function! MySys()
if has("win16") || has("win32") || has("win64") || has("win95")
return "windows"
elseif has("unix")
return "linux"
endif
endfunction

" 用戶目錄變量$VIMFILES
if MySys() == "windows"
let $VIMFILES = $VIM.'/vimfiles'
elseif MySys() == "linux"
let $VIMFILES = $HOME.'/.vim'
endif

" 設(shè)定doc文檔目錄
let helptags=$VIMFILES.'/doc'

" 設(shè)置字體 以及中文支持
if has("win32")
set guifont=Inconsolata:h22:cANSI
endif

" 配置多語言環(huán)境
if has("multi_byte")
" UTF-8 編碼
set encoding=utf-8
set termencoding=utf-8
set formatoptions+=mM
set fencs=utf-8,gbk

if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif

if has("win32")
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_CN.utf-8
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif

" Buffers操作快捷方式!
nnoremap <C-RETURN> :bnext<CR>
nnoremap <C-S-RETURN> :bprevious<CR>

" Tab操作快捷方式!
nnoremap <C-TAB> :tabnext<CR>
nnoremap <C-S-TAB> :tabprev<CR>

"關(guān)于tab的快捷鍵
" map tn :tabnext<cr>
" map tp :tabprevious<cr>
" map td :tabnew .<cr>
" map te :tabedit
" map tc :tabclose<cr>

"窗口分割時(shí),進(jìn)行切換的按鍵熱鍵需要連接兩次,比如從下方窗口移動
"光標(biāo)到上方窗口,需要<c-w><c-w>k,非常麻煩,現(xiàn)在重映射為<c-k>,切換的
"時(shí)候會變得非常方便.
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

"一些不錯(cuò)的映射轉(zhuǎn)換語法(如果在一個(gè)文件中混合了不同語言時(shí)有用)
nnoremap <leader>1 :set filetype=xhtml<CR>
nnoremap <leader>2 :set filetype=css<CR>
nnoremap <leader>3 :set filetype=javascript<CR>
nnoremap <leader>4 :set filetype=php<CR>

" set fileformats=unix,dos,mac
" nmap <leader>fd :se fileformat=dos<CR>
" nmap <leader>fu :se fileformat=unix<CR>

" use Ctrl+[l|n|p|cc] to list|next|previous|jump to count the result
" map <C-x>l <ESC>:cl<CR>
" map <C-x>n <ESC>:cn<CR>
" map <C-x>p <ESC>:cp<CR>
" map <C-x>c <ESC>:cc<CR>


" 讓 Tohtml 產(chǎn)生有 CSS 語法的 html
" syntax/2html.vim,可以用:runtime! syntax/2html.vim
let html_use_css=1

" Python 文件的一般設(shè)置,比如不要 tab 等
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab
autocmd FileType python map <F12> :!python %<CR>

" 選中狀態(tài)下 Ctrl+c 復(fù)制
vmap <C-c> "+y

" 打開javascript折疊
let b:javascript_fold=1
" 打開javascript對dom、html和css的支持
let javascript_enable_domhtmlcss=1
" 設(shè)置字典 ~/.vim/dict/文件的路徑
autocmd filetype javascript set dictionary=$VIMFILES/dict/javascript.dict
autocmd filetype css set dictionary=$VIMFILES/dict/css.dict
autocmd filetype php set dictionary=$VIMFILES/dict/php.dict

"-----------------------------------------------------------------
" plugin - bufexplorer.vim Buffers切換
" \be 全屏方式查看全部打開的文件列表
" \bv 左右方式查看 \bs 上下方式查看
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin - taglist.vim 查看函數(shù)列表,需要ctags程序
" F4 打開隱藏taglist窗口
"-----------------------------------------------------------------
if MySys() == "windows" " 設(shè)定windows系統(tǒng)中ctags程序的位置
let Tlist_Ctags_Cmd = '"'.$VIMRUNTIME.'/ctags.exe"'
elseif MySys() == "linux" " 設(shè)定windows系統(tǒng)中ctags程序的位置
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
endif
nnoremap <silent><F4> :TlistToggle<CR>
let Tlist_Show_One_File = 1 " 不同時(shí)顯示多個(gè)文件的tag,只顯示當(dāng)前文件的
let Tlist_Exit_OnlyWindow = 1 " 如果taglist窗口是最后一個(gè)窗口,則退出vim
let Tlist_Use_Right_Window = 1 " 在右側(cè)窗口中顯示taglist窗口
let Tlist_File_Fold_Auto_Close=1 " 自動折疊當(dāng)前非編輯文件的方法列表
let Tlist_Auto_Open = 0
let Tlist_Auto_Update = 1
let Tlist_Hightlight_Tag_On_BufEnter = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Process_File_Always = 1
let Tlist_Display_Prototype = 0
let Tlist_Compact_Format = 1


"-----------------------------------------------------------------
" plugin - mark.vim 給各種tags標(biāo)記不同的顏色,便于觀看調(diào)式的插件。
" \m mark or unmark the word under (or before) the cursor
" \r manually input a regular expression. 用于搜索.
" \n clear this mark (i.e. the mark under the cursor), or clear all highlighted marks .
" \* 當(dāng)前MarkWord的下一個(gè) \# 當(dāng)前MarkWord的上一個(gè)
" \/ 所有MarkWords的下一個(gè) \? 所有MarkWords的上一個(gè)
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin - NERD_tree.vim 以樹狀方式瀏覽系統(tǒng)中的文件和目錄
" :ERDtree 打開NERD_tree :NERDtreeClose 關(guān)閉NERD_tree
" o 打開關(guān)閉文件或者目錄 t 在標(biāo)簽頁中打開
" T 在后臺標(biāo)簽頁中打開 ! 執(zhí)行此文件
" p 到上層目錄 P 到根目錄
" K 到第一個(gè)節(jié)點(diǎn) J 到最后一個(gè)節(jié)點(diǎn)
" u 打開上層目錄 m 顯示文件系統(tǒng)菜單(添加、刪除、移動操作)
" r 遞歸刷新當(dāng)前目錄 R 遞歸刷新當(dāng)前根目錄
"-----------------------------------------------------------------
" F3 NERDTree 切換
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC>:NERDTreeToggle<CR>


"-----------------------------------------------------------------
" plugin - NERD_commenter.vim 注釋代碼用的,
" [count],cc 光標(biāo)以下count行逐行添加注釋(7,cc)
" [count],cu 光標(biāo)以下count行逐行取消注釋(7,cu)
" [count],cm 光標(biāo)以下count行嘗試添加塊注釋(7,cm)
" ,cA 在行尾插入 /* */,并且進(jìn)入插入模式。 這個(gè)命令方便寫注釋。
" 注:count參數(shù)可選,無則默認(rèn)為選中行或當(dāng)前行
"-----------------------------------------------------------------
let NERDSpaceDelims=1 " 讓注釋符與語句之間留一個(gè)空格
let NERDCompactSexyComs=1 " 多行注釋時(shí)樣子更好看


"-----------------------------------------------------------------
" plugin - DoxygenToolkit.vim 由注釋生成文檔,并且能夠快速生成函數(shù)標(biāo)準(zhǔn)注釋
"-----------------------------------------------------------------
let g:DoxygenToolkit_authorName="Asins - asinsimple AT gmail DOT com"
let g:DoxygenToolkit_briefTag_funcName="yes"
map <leader>da :DoxAuthor<CR>
map <leader>df :Dox<CR>
map <leader>db :DoxBlock<CR>
map <leader>dc a /* */<LEFT><LEFT><LEFT>


"-----------------------------------------------------------------
" plugin – ZenCoding.vim 很酷的插件,HTML代碼生成
" 插件最新版:http://github.com/mattn/zencoding-vim
" 常用命令可看:http://nootn.com/blog/Tool/23/
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin – checksyntax.vim JavaScript常見語法錯(cuò)誤檢查
" 默認(rèn)快捷方式為 F5
"-----------------------------------------------------------------
let g:checksyntax_auto = 0 " 不自動檢查


"-----------------------------------------------------------------
" plugin - NeoComplCache.vim 自動補(bǔ)全插件
"-----------------------------------------------------------------
let g:AutoComplPop_NotEnableAtStartup = 1
let g:NeoComplCache_EnableAtStartup = 1
let g:NeoComplCache_SmartCase = 1
let g:NeoComplCache_TagsAutoUpdate = 1
let g:NeoComplCache_EnableInfo = 1
let g:NeoComplCache_EnableCamelCaseCompletion = 1
let g:NeoComplCache_MinSyntaxLength = 3
let g:NeoComplCache_EnableSkipCompletion = 1
let g:NeoComplCache_SkipInputTime = '0.5'
let g:NeoComplCache_SnippetsDir = $VIMFILES.'/snippets'
" <TAB> completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" snippets expand key
imap <silent> <C-e> <Plug>(neocomplcache_snippets_expand)
smap <silent> <C-e> <Plug>(neocomplcache_snippets_expand)


"-----------------------------------------------------------------
" plugin - matchit.vim 對%命令進(jìn)行擴(kuò)展使得能在嵌套標(biāo)簽和語句之間跳轉(zhuǎn)
" % 正向匹配 g% 反向匹配
" [% 定位塊首 ]% 定位塊尾
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin - vcscommand.vim 對%命令進(jìn)行擴(kuò)展使得能在嵌套標(biāo)簽和語句之間跳轉(zhuǎn)
" SVN/git管理工具
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin – a.vim
"-----------------------------------------------------------------

分享標(biāo)題:vim配置詳解
標(biāo)題網(wǎng)址:http://bm7419.com/article20/jjsico.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google企業(yè)網(wǎng)站制作、網(wǎng)站制作、網(wǎng)站建設(shè)、小程序開發(fā)、網(wǎng)頁設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)