【常用vimrc配置 请自取】

"vim基 本 配 置                                                                                                                                     
set fileencodings=utf-8,gb2312                                                          "编 辑 和 保 存 文 件 所 使 用 的 编 码                              
set fileencoding=utf-8                                                                  "新 建 文 件 所 使 用 的 编 码                                    
set termencoding=utf-8                                                                  "终 端 所 显 示 的 编 码                                        
set encoding=utf-8                                                                      "vim的 缓 冲 区 、 菜 单 文 本 和 消 息 文 本 使 用 的 编 码               
set shiftwidth=4                                                                        "自 动 缩 进 长 度 为 4空 格                                     
set tabstop=4                                                                           "设 置 tab长 度 为 4空 格                                      
set softtabstop=4                                                                       "tab键 的 实 际 占 有 空 格 数 , 统 一 缩 进                         
set autoindent                                                                          "自 动 缩 进 开 关                                            
set showmatch                                                                           "高 亮 显 示 括 号 匹 配                                        
set ruler                                                                               "右 下 角 显 示 当 前 光 标 位 置                                  
set hlsearch                                                                            "高 亮 显 示 搜 索 结 果                                        
set nu                                                                                  "显 示 行 号                                                
set laststatus=2                                                                        "1=启 动 显 示 状 态 行 、 2=总 是 显 示 状 态 行                      
set t_Co=256                                                                            "terminal Color 开 启 256色 支 持                            
syntax enable                                                                           "语 法 高 亮 显 示                                            
set backspace=2                                                                         "indet,eol,start                                        
set incsearch                                                                           "输 入 字 符 串 就 显 示 匹 配 点                                  
set cindent                                                                             "以 C语 言 的 方 式 缩 进                                       
                                                                                                                                                
"set laststatus=2                                                                                                                               
function! ShowCurrentDirectory()                                                                                                                
    let current_dir = substitute(getcwd(), $HOME, "~", "g")                                                                                     
    return current_dir                                                                                                                          
endfunction                                                                                                                                     
set statusline=[%n]\ %f%m%r%h\ \|\ %{ShowCurrentDirectory()}\/%f\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b,hex=%b%{((&fenc==\"\")?\"\":\"\ \|\ \".&fe
nc)}\ \|\ %{$USER}\ @\ %{hostname()}\                                                                                                           
                                                                                                                                                
"记 住 上 次 打 开 的 位 置                                                                                                                              
set viminfo='10,\"100,:20,%,n~/.viminfo                                                                                                         
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|exe "norm $"|endif|endif                                        
                                                                                                                                                
"列 出 函 数 导 航                                                                                                                                    
nnoremap <silent> <F8> :TlistToggle                                                                                                         
                                                                                                                                                
"垂 直 尺 寸 左 右 移 动                                                                                                                                
nnoremap w[ :vertical resize -6                                                                                                             
nnoremap w] :vertical resize +6                                                                                                             
                                                                                                                                                
"水 平 尺 寸 上 下 移 动                                                                                                                                
nnoremap w- :resize -6                                                                                                                      
nnoremap w= :resize +6                                                                                                                      
                                                                                                                                                
"敲 成 对 括 号 自 动 按 Left键                                                                                                                          
imap () ()<Left>                                                                                                                                
imap [] []<Left>                                                                                                                                
imap {} {}<Left>                                                                                                                                
imap "" ""<Left>                                                                                                                                
imap '' ''<Left>                                                                                                                                
                                                                                                                                                                                                                       
"插 入 模 式 下 移 动 光 标 快 捷 键                                                                                                                        
inoremap <C-h> <Left>                                                                                                                             
inoremap <C-j> <Down>                                                                                                                              
inoremap <C-k> <Up>                                                                                                                               
inoremap <C-l> <Right>                                                                                                                            
                                                                                                                   
                                                                                                                                                
"自 动 保 存 设 置                                                                                                                                    
autocmd BufWritePost $MYVIMRC source $MYVIMRC                                           "该 配 置 文 件 修 改 保 存 后 立 即 生 效                            
                                                                                                                                                
"ctags配 置                                                                                                                                       
set tags=tags;                                                                          "查 找 tags文 件                                            
set autochdir                                                                           "自 动 切 换 目 录 查 找                                        
                                                                                                                                                
"cscope配 置                                                                                                                                      
set csprg=/usr/bin/cscope                                                                                                                       
set csto=0                                                                              "设 置 cstag命 令 查 找 次 序 ,0先 找 cscope数 据 库 再 找 tag标 签 文 件  
set cst                                                                                 "同 时 搜 索 cscope数 据 库 和 标 签 文 件                          
set nocsverb                                                                            "不 对 下 面 的 数 据 库 加 载 信 息 进 行 回 显                        
if filereadable("cscope.out")                                                                                                                   
        "加 载 数 据 库                                                                                                                              
        cs add cscope.out                                                                                                                       
else                                                                                                                                            
        let cscope_file=findfile("cscope.out",".;")                                                                                             
        let cscope_pre=matchstr(cscope_file,".*/")                                                                                              
        if !empty(cscope_file) && filereadable(cscope_file)                                                                                     
                exe "cs add" cscope_file cscope_pre                                                                                             
        endif                                                                                                                                   
endif                                                                                                                                           
set csverb                                                                               "打 开 配 置 回 显                                           
                                                                                                                                                
"cscope快 捷 键 设 置                                                                                                                                
nmap s :cs find s =expand("")                                                                                          
nmap g :cs find g =expand("")                                                                                          
nmap c :cs find c =expand("")                                                                                          
nmap t :cs find t =expand("")                                                                                          
nmap e :cs find e =expand("")                                                                                          
nmap f :cs find f =expand("")                                                                                          
nmap i :cs find i =expand("")                                                                                          
nmap d :cs find d =expand("")                                                                                          

上面涉及到的插件是cscope与ctags,请道友们自行安装,道友有好的建议请在评论补充。


版权声明:本文为liushunCSDNblog原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。