.vimrc配置

set runtimepath^=~/.vim/bundle/ctrlp.vim
set runtimepath^=~/.vim/bundle/vim-json.vim
augroup filetype
autocmd! BufRead,BufNewFile BUILD set filetype=blade
augroup end
au BufReadPost * if line("'\"") > 0 | if line("'\"") <= line("$") | exe("norm '\"") | else | exe "norm $" | endif | endif
set hlsearch
colorscheme ron
set formatoptions=tcrqn
set nocp
set encoding=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set fileencodings=utf-8,ucs-bom,chinese
set langmenu=zh_CN.UTF-8
syntax enable
set cursorline
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
set selection=exclusive
set selectmode=mouse,key
set nu
set showmatch
set nocompatible
set tabstop=2
set softtabstop=2
set shiftwidth=2
set autoindent
set cindent
set ts=2
set sw=2
set sts=2
set ignorecase
set expandtab
syntax on
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif

filetype on
let Tlist_Show_One_File=0
let Tlist_File_Fold_Auto_Close=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_SingleClick=1
let Tlist_GainFocus_On_ToggleOpen=1
let Tlist_Process_File_Always=1
filetype plugin indent on
set completeopt=longest,menu
set shell=bash
set history=400

map <C-l> :Tlist<CR>

if exists("&autoread")
set autoread
endif

set ambiwidth=double
set ffs=unix,dos,mac
set incsearch
set noerrorbells
set novisualbell
set nobackup
set nowb
set backspace=2
if has('mouse')
set mouse-=a
endif

autocmd BufNewFile *.[ch],*.hpp,*.cpp,*.cc exec ":call SetTitle()"

func SetComment()
call setline(1,"/*")
call append(line("."), " * Copyright (C) ".strftime("%Y")." XX All rights reserved.")
call append(line(".")+1, " *")
call append(line(".")+2, " * Author:San Zhang (zhangsan@xx.com)")
call append(line(".")+3, " * Date:".strftime("%Y-%m-%d"))
call append(line(".")+4, " */")
endfunc

func SetTitle()
call SetComment()
if expand("%:e") == 'hpp'
call append(line(".")+5, "#ifndef _".toupper(expand("%:t:r"))."_H")
call append(line(".")+6, "#define _".toupper(expand("%:t:r"))."_H")
call append(line(".")+7, "#ifdef __cplusplus")
call append(line(".")+8, "extern \"C\"")
call append(line(".")+9, "{")
call append(line(".")+10, "#endif")
call append(line(".")+11, "")
call append(line(".")+12, "#ifdef __cplusplus")
call append(line(".")+13, "}")
call append(line(".")+14, "#endif")
call append(line(".")+15, "#endif //".toupper(expand("%:t:r"))."_H")
elseif expand("%:e") == 'h'
call append(line(".")+5, "#pragma once")
elseif &filetype == 'c'
call append(line(".")+5,"#include \"".expand("%:t:r").".h\"")
elseif &filetype == 'cpp'
call append(line(".")+5, "#include \"".expand("%:t:r").".h\"")
endif
endfunc

posted @ 2023-03-15 09:40  郭流水  阅读(115)  评论(0编辑  收藏  举报