vimrc配置文件

" 不指定文件名打开新文件时不显示版本信息和乌干达儿童的提示
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

SEE ALSO

vim字符编码详解
vim缩进设置详解

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值