前言
需要注意的是 在使用之前 需要将 文件头部 global variables 部分 的变量名 根据自己的实际情况来设置一下 否则 闹出版权纠纷就大麻烦了
实际配置文件内容如下:
" FACIL: abodu notice once
" DESP: vim settings
" AUTHOR: Liu Dongguo
" ChgOn: 2015-04-14 07:00:42
" WebSite: http://www.github.com/jealdean/abodu
"
" GLOBAL-VARIABLES {{{1
let g:mapleader=‘;‘
let g:author=‘Liu Dongguo‘
let g:email=‘jealdean@outlook.com‘
let g:strVersion=‘1.0‘
let g:startyear=‘2007‘
let g:org=‘Abodu.com, Inc. All Rights Reserved‘
"TIPS-FOR-ALL {{{1
"notice:
" n: normal mode
" i: insert mode
" c: command mode
" v: view mode
" <c-KEY> : 的含义是 按下Ctrl 迅速再按下 ‘KEY‘
"TIP 1. 快速匹配括号 及 #if #else #endif
"n: % (first chang into normal mode,and press shift + 5)
"TIP 2. 快速查找当前光标位置处系统函数的 Man手册
"n: K (first chang into normal mode,and press shift + K)
"TIP 3. 快速跳转到相应的头文件处
"n: gf (需要光标在头文件名字中)
"n: <ctrl-o> (跳回到原处)
"TIP 4.查看已经设置的vim的选项
"c: set [all]
"TIP 5.折叠
"关闭全部代码折叠功能
"n: zM
"打开/关闭 某一个折叠的代码块
"n:<space> (普通模式下按一次空格)
"GENERAL-SETTINGS {{{1
"common {{{2
syn on "开启语法高亮
set sm "设置匹配模式
set ai "自动对齐
set si "智能对齐
filetype on "开启类型检测
filetype plugin on "为指定类型的文件加载plugin
filetype indent on "
filetype plugin indent on "可以使用智能补全
set completeopt=longest,menu "关掉智能补全时的预览窗口
set path=.,include,../include,../../include,/usr/include "当打开头文件的时候,自动搜索的路径
set path+=/usr/include/mysql "add for mysql
set path+=/usr/src/kernel/include "add for linux kernel
"colors {{{2
set t_Co=256 "支持256色
colorscheme ron "主题
"colorscheme peaksea
" Encodings {{{2
set encoding=utf-8
set fenc=utf-8
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936,chinese
set ambiwidth=double
"folds {{{2
set foldenable "开启折叠
set foldmethod=syntax "默认标记方式
set foldcolumn=2 "折叠边宽
"set foldclose=all "自动关闭折叠
set foldlevel=100 "默认不折叠
nnoremap <space> @=((foldclosed(line(‘.‘))<0)?‘zc‘:‘zo‘)<cr>
"tab {{{2
set nu "显示行数
set list lcs=tab:\|\ "Tab 被替换显示成|
set noet "不用空格扩展Tab"
set ts=4 "Tab的宽度,单位是一个空格宽
set sw=4
"status line {{{2
set laststatus=2 "总是显示状态栏
set stl=%F[%1*%M%*%n%R%H%w%m%h][%{strftime(\"%Y%m%d-%H:%M\")}][%l,%v,%p%%]\ %=\
set stl+=%0([%{&ft},%{&fileformat},%{&fileencoding}]%)\
"search and subst {{{2
set incsearch "跳转到当前匹配位置
set hlsearch "高亮显示搜索结果
set ignorecase "不区分大小写
set gdefault "替换时所有的行内匹配都被替换,而不是只有第一个
set autochdir "自动设置目录为正在编辑的文件所在目录
set backspace=2 "设置退格键可用,等同于indent,eol,start
"others {{{2
set hidden "没有保存的缓冲区可以自动被隐藏
set linebreak "整词换行
set nobackup "不自动备份
set nocp "不兼容vi模式
set sc "在状态栏显示正在输入的命令
set nowrap "不自动换行
set vb t_vb= "不提示错误响声
set wig=*.bak,*.o,*.e,*~ "tab键的自动完成现在会忽略这些后缀名的文件
set ttimeoutlen=100 ""
"PLUGINS {{{1
"csupport {{{2
"
let g:C_CFlags=‘-Wall -g -O0 -c -I/usr/include/mysql -I../../include‘
let g:C_Libs=‘-lm -lpthread -L/usr/lib64/mysql -lmysqlclient‘
let g:C_CplusFlags=g:C_CFlags
let g:C_CplusLibs=g:C_Libs
let g:C_TypeOfH=‘CPP‘
let g:C_InsertFileHeader =‘no‘
let g:C_BraceOnNewLine=‘yes‘
let g:C_MapLeader=‘;‘
let g:C_Comments=‘no‘
" echofunc{{{2
nmap efc <Esc>:!sudo ctags -f /usr/include/systags -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS --extra=+q /usr/include/* /usr/include/sys/* /usr/include/bits/* /usr/include/netinet/* /usr/include/arpa/* /usr/src/kernel/include/* /usr/include/mysql/*<CR>
set tags=/usr/include/systags
"
" taglist {{{2
let Tlist_Auto_Open=0
let Tlist_WinWidth=38
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=0
let Tlist_Close_On_Select=1
let Tlist_File_Fold_Auto_Close = 0
let Tlist_GainFocus_On_ToggleOpen=1
let Tlist_Display_Prototype = 1
nmap tl :TlistToggle<cr>
" }}}
"windowmanager{{{2
let g:winManagerWidth=g:Tlist_WinWidth
let g:winManagerWindowLayout=‘TagList|FileExplorer‘
let g:wiw=60
nmap wm :WMToggle<cr>
"MAPPINGS {{{1
"basic mapping {{{2
"F1 - overrule Linux F1
map <silent> <F1> <esc>:exec "help ".expand("<cword>")<cr>
"F2 - call file explorer Ex
map <silent> <F2> :Explore<cr>
imap <silent> <F2> <esc>:Explore<cr>
"F3 - remove trail white-space
map <silent> <F3> :%s/[ \r]\+$//g<cr>
imap <silent> <F3> <esc>:%s/[ \r]\+$//g<cr>
"F4 - change to next buffer
map <silent> <F4> :bNext<cr>
imap <silent> <F4> <esc>:bNext<cr>
"F10- 开启/关闭粘贴模式
set pastetoggle=<F10>
"insert space after some characters{{{2
inoremap , ,
inoremap = =
inoremap - -
inoremap + +
inoremap < <
inoremap > >
inoremap -- --
inoremap ++ ++
inoremap >> >>
inoremap << <<
inoremap && &&
inoremap == ==
inoremap != !=
inoremap += +=
inoremap <= <=
inoremap >= >=
inoremap /= /=
inoremap *= *=
"FUNCTIONS{{{1
"UD_CodeFormat {{{2
func! UD_CodeFormat()
silent exec "ks| normal gg=G|‘s"
endf
"UD_AIAdd{{{2
func! UD_AIAdd()
let n = 1
while n < 5
let line=getline(n)
if (line =~ ‘^#!\/bin\/.*$‘ || line =~ ‘^\/.*$‘)
return
endif
let n+=1
endwhile
"make some local variables
let lCP=‘ Copyright (c) ‘.g:startyear.‘ - ‘.strftime(‘%Y‘).‘ ‘.g:org
let lGL=‘************************************************************************‘
let lName =‘ NAME: ‘.expand(‘%:t‘)
let lDesc =‘ DESC: ‘
let lAuthor =‘ AUTHOR: ‘.g:author.‘(‘.g:email.‘)‘
let lVersion=‘ VERSION: ‘.g:strVersion
let lCrTime =‘ CREATE: ‘.strftime(‘%Y-%m-%d %T‘)
let lLuTime =‘ LUTIME: ‘.strftime(‘%Y-%m-%d %T‘)
let lPF=‘ *‘
let lGLS=‘/*‘
let lGLE=‘ */‘
let lExt=expand(‘%:p:e‘)
if (lExt == ‘sh‘ || lExt == ‘pl‘ || lExt == ‘awk‘)
let lPF=‘#‘
let lGLE=‘#‘
let lGLS=‘#!/bin/sh‘
if lExt == ‘pl‘
let lGLS=‘#!/bin/perl‘
elseif lExt == ‘awk‘
let lGLS=‘#!/bin/awk‘
endif
endif
call append(0,[lGLS
\,lPF.lGL
\,lPF.lName,lPF.lDesc,lPF.lAuthor,lPF.lVersion,lPF.lCrTime,lPF.lLuTime
\,lPF
\,lPF.lCP
\,lPF
\,lPF.lGL
\,lGLE])
endfunc
"UD_AIDetect{{{2
func! UD_AIDetect()
let n=1
let updated=0
while n<10
let line=getline(n)
if (line =~ ‘.*NAME.*‘ || line =~ ‘.*FileName.*‘ || line =~ ‘.*Title.*‘)
let newline=substitute(line,‘:.*$‘,‘: ‘.expand(‘%:t‘),‘g‘)
call setline(n,newline)
let updated = 1
elseif ( line =~ ‘.*LUTIME.*‘ || line =~ ‘.*ChgOn.*‘ || line =~ ‘.*LastChangedTime.*‘ )
let newline=substitute(line,‘:.*$‘,‘: ‘.strftime(‘%Y-%m-%d %T‘),‘g‘)
call setline(n,newline)
let updated = 1
endif
let n+=1
endwhile
if updated == 0
call UD_AIAdd()
endif
endfunc
"AUTOCMDS {{{1
if has("autocmd")
au BufEnter * :lch %:p:h
"au BufReadPost * if line("‘\"") > 0 && line("‘\"") <= line("$") | exe "normal! g`\"" | endif
au InsertEnter * set cul cursorline cursorcolumn
au InsertLeave * set nocul nocursorline nocursorcolumn
au BufRead,BufNewFile make*,Make*,*mk* set ft=make
au FileType c,cpp,java,make set noet nu fen ts=4 sw=4 tw=80
au BufRead,BufNewFile *vimrc set nu fen et ft=vim tw=80 fdm=marker fdl=100
"au BufWritePre,FileWritePre,FileAppendPre *.sh,*.c,*.cpp,*.cc,*h,*.hpp :silent call UD_CodeFormat()
au BufNewFile,BufNew *.sh,*.awk,*.pl,*.c,*.cpp,*.cc,*h,*.hpp :silent call UD_AIAdd()
au BufWritePre,FileWritePre,FileAppendPre *vimrc,*.sh,*.awk,*.pl,*.c,*.cpp,*.cc,*h,*.hpp,README :silent call UD_AIDetect()
endif " has (autocmd)"
" CSUPPORT-HOTKEYS {{{1
"Legend: (i) insert mode, (n) normal mode, (v) visual mode
" [n] range
"
"-- Help ---------------------------------------------------------------
"
" ;he open an English dictionary for the (n,i)
" word under the cursor
" ;hd open the reference for the Doxygen (n,i)
" command under the cursor
" ;hm show manual for word under the cursor (n,i)
" ;hp show plugin help (n,i)
"
"-- Comments -----------------------------------------------------------
"
" [n];cl end-of-line comment (n,v,i)
" [n];cj adjust end-of-line comment(s) (n,v,i)
" ;cs set end-of-line comment column (n)
" [n];c* code -> comment /* */ (n,v,i)
" [n];cc code -> comment // (n,v,i)
" [n];co comment -> code (n,v,i)
" [n];cn toggle non-C comment (n,v,i)
" ;cfr frame comment (n,i)
" ;cfu function comment (n,i)
" ;cme method description (n,i)
" ;ccl class description (n,i)
" ;cfdi file description (implementation) (n,i)
" ;cfdh file description (header) (n,i)
" ;ccs C/C++-file section (tab. compl.) (n,i)
" ;chs H-file section (tab. compl.) (n,i)
" ;ckc keyword comment (tab. compl.) (n,i)
" ;csc special comment (tab. compl.) (n,i)
" ;cma plugin macros (tab. compl.) (n,i)
" ;cd date (n,v,i)
" ;ct date ;& time (n,v,i)
" [n];cx toggle comments: C <--> C++ (n,v,i)
"
"-- Statements ---------------------------------------------------------
"
" ;sd do { } while (n,v,i)
" ;sf for (n,i)
" ;sfo for { } (n,v,i)
" ;si if (n,i)
" ;sif if { } (n,v,i)
" ;sie if else (n,v,i)
" ;sife if { } else { } (n,v,i)
" ;se else { } (n,v,i)
" ;sw while (n,i)
" ;swh while { } (n,v,i)
" ;ss switch (n,v,i)
" ;sc case (n,i)
" ;sb {} (n,v,i)
"
"-- Idioms -------------------------------------------------------------
"
" ;if function (n,v,i)
" ;isf function static (n,v,i)
" ;im main() (n,v,i)
" ;ie enum + typedef (n,i)
" ;is struct + typedef (n,i)
" ;iu union + typedef (n,i)
" ;isc scanf() (n,i)
" ;ipr printf() (n,i)
" ;ica p=calloc() (n,i)
" ;ima p=malloc() (n,i)
" ;ire p=realloc() (n,i)
" ;isi sizeof() (n,v,i)
" ;ias assert() (n,v)
" ;ii open input file (n,i)
" ;io open output file (n,i)
" ;ifsc fscanf (n,i)
" ;ifpr fprintf (n,i)
" [n];i0 for( x=0; x<n; x+=1 ) (n,v,i)
" [n];in for( x=n-1; x>=0; x-=1 ) (n,v,i)
"
"-- Preprocessor -------------------------------------------------------
"
" ;pih include standard library header (n,i)
" ;pg #include <> (global) (n,i)
" ;pl #include "" (local) (n,i)
" ;pd #define (n,i)
" ;pu #undef (n,i)
" ;pif #if #endif (n,v,i)
" ;pie #if #else #endif (n,v,i)
" ;pid #ifdef #else #endif (n,v,i)
" ;pin #ifndef #else #endif (n,v,i)
" ;pind #ifndef #def #endif (n,v,i)
" ;pe #error (n,i)
" ;pl #line (n,i)
" ;pp #pragma (n,i)
" ;pw #warning (n,i)
" ;pi0 #if 0 #endif (n,v,i)
" ;pr0 remove #if 0 #endif (n,i)
"
"-- Snippets -----------------------------------------------------------
"
" ;nr read code snippet (n,i)
" ;nv view code snippet (read-only) (n,i)
" ;nw write code snippet (n,v,i)
" ;ne edit code snippet (n,i)
"
" [n];nf pick up function prototype (n,v,i)
" [n];np pick up function prototype (n,v,i)
" [n];nm pick up method prototype (n,v,i)
" ;ni insert prototype(s) (n,i)
" ;nc clear prototype(s) (n,i)
" ;ns show prototype(s) (n,i)
"
" ;ntl edit local templates (n,i)
" ;ntr reread templates (n,i)
" ;njt include jump tags (n,i)
"
"-- C++ ----------------------------------------------------------------
"
" ;+ih include C++ standard library header (n,i)
" ;+ich include C standard library header (n,i)
" ;+om output manipulators (n,i)
" ;+fb ios flag bits (n,i)
" ;+c class (n,i)
" ;+cn class (using new) (n,i)
" ;+tc template class (n,i)
" ;+tcn template class (using new) (n,i)
" ;+ec error class (n,i)
" ;+tf template function (n,i)
" ;+tr try ... catch (n,v,i)
" ;+ca catch (n,v,i)
" ;+caa catch(...) (n,v,i)
" ;+ex extern "C" { } (n,v,i)
" ;+oif open input file (n,v,i)
" ;+oof open output file (n,v,i)
" ;+uns using namespace std; (n,v,i)
" ;+un using namespace xxx; (n,v,i)
" ;+unb namespace xxx { } (n,v,i)
" ;+na namespace alias (n,v,i)
" ;+rt RTTI (n,v,i)
"
" ;+ic class implementation (n,i)
" ;+icn class (using new) implementation (n,i)
" ;+im method implementation (n,i)
" ;+ia accessor implementation (n,i)
" ;+itc template class implementation (n,i)
" ;+itcn template class (using new) impl. (n,i)
" ;+itm template method implementation (n,i)
" ;+ita template accessor implementation (n,i)
" ;+ioi operator >> (n,i)
" ;+ioo operator << (n,i)
"
"-- Run ----------------------------------------------------------------
"
" ;rc save and compile (n,i)
" ;rl link (n,i)
" ;rr run (n,i)
" ;ra set comand line arguments (n,i)
" ;rd run debugger (n,i)
"
" ;re executable to run (n,i)
"
" ;rp run splint (n,i)
" ;rpa cmd. line arg. for splint (n,i)
" ;rcc run cppcheck (n,i)
" ;rccs severity for cppcheck (n,i)
" ;rk run CodeCheck (TM) (n,i)
" ;rka cmd. line arg. for CodeCheck (TM) (n,i)
" ;ri run indent (n,v,i)
" [n];rh hardcopy buffer (n,v,i)
" ;rs show plugin settings (n,i)
" ;rx set xterm size (n, only Linux/UNIX & GUI)
" ;ro change output destination (n,i)
" }}}
" /* vim: set ft=vim nu ts=4 sw=4 tw=80: */
时间: 2024-11-09 16:08:49