" 不指定文件名打开新文件时不显示版本信息和乌干达儿童的提示
set shortmess+=I
" 行号显示
set nu
" 显示小括号、大括号等的匹配
set showmatch
"设置Tab长度为4空格
set tabstop=4
"设置自动缩进长度为4空格
set shiftwidth=4
"继承前一行的缩进方式,适用于多行注释
set cindent
"设置满79行自动换行,符合gnu编码规范,并自动增加注释符
set textwidth=79
set formatoptions+=mMcro
" 打开的文件若不是Makefile,则展开tab为2空格
:let filename=expand('%:t')
if filename!="Makefile" && filename!="makefile"
"将tab扩展为空格
set expandtab
"设置Tab长度为2空格
set tabstop=2
"设置自动缩进长度为2空格
set shiftwidth=2
endif
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
let mapleader = ","
" 打开.vimrc
nnoremap <leader>ev :vsplit $MYVIMRC<CR>
" 重新加载.vimrc以使新配置立即生效
nnoremap <leader>sv :source $MYVIMRC<CR>
" 将插入模式下jk按键的连续敲击视为返回normal模式
inoremap jk <ESC>
" F2插入方法注释模板
inoremap <F2> <ESC>:call GenerateFuncComment()<CR>
nnoremap <F2> :call GenerateFuncComment()<CR>
function GenerateFuncComment()
"all lines of the template
let l:comlines = 17
let l:count = 0
normal! k
"line number of the first line of the comment
let l:firstline = line(".")
call append(l:firstline, "/******************************************************************************")
call append(l:firstline+1, "* Function Name: ")
call append(l:firstline+2, "*")
call append(l:firstline+3, "* Parameter:")
call append(l:firstline+4, "* @argu1 this is the argu1")
call append(l:firstline+5, "* @argu2 this is the argu2")
call append(l:firstline+6, "*")
call append(l:firstline+7, "* Description: Hrer are the description.")
call append(l:firstline+8, "*")
call append(l:firstline+9, "* Return: Here are the return.")
call append(l:firstline+10, "*")
call append(l:firstline+11, "* NOTE:")
call append(l:firstline+12, "* 1. note1")
call append(l:firstline+13, "* 2. note2")
call append(l:firstline+14, "*")
call append(l:firstline+15, "* Date: ".strftime("%Y-%m-%d"))
call append(l:firstline+16, "* Author: jiliang.cai@ucas.com.cn")
call append(l:firstline+17, "******************************************************************************/")
"定位到Function Name:行尾
normal! jj$
endfunction
vimrc配置文件
最新推荐文章于 2024-07-29 20:22:37 发布