快速添加代码修改注释
1.快捷 代码修改注释 是基于在linux的vim编辑工具上大家先得安装vim以及git(git版本控制工具,这是为了方便拿到个人信息、这个大家看了脚本也可以自己修改)?
2.安装好以上2个工具后首先配置好自己的git信息
个人如下eg:
$ git config --global user.name "hehangjun"
$ git config --global user.email hehangjun@hongyucom.com
3.然后在vim的配置文件中添加如下脚本:
"Set mapleader
let mapleader = ","
let g:mapleader = ","
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <silent> <F8> :%s/?/??? /g<cr>
map <silent> <F9> :%s/\s\+$//g<cr>
"used for add code or delete/update code
"for java & C/C++
map <leader>fj o<ESC>0i/* hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>$a on:<Esc>:read !date -R <CR><ESC>kJ$o<ESC>0i * TODO: replace this line with your comment<CR><Esc>0a */<CR><CR><Esc>0i// End of hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>k
vmap <leader>fj xO<Esc>0i/* hongyu:<CR><Esc>k:read !git config --get user.name<CR>kJi<Del><Esc>$a on:<CR><Esc>k:read !date -R <CR><ESC>kJ$o<ESC>0i * TODO: replace this line with your comment<Esc>gp<Esc>0a */<CR><CR><Esc>0i// End of hongyu:<Esc>:read !git config --get user.name<CR>kJJ<Del>k
"for perl
map <leader>fp o<ESC>0i# hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>$a on:<Esc>:read !date -R <CR><ESC>kJ$o<ESC>0i# TODO: replace this line with your comment<CR><CR><Esc>0i# End of hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>k
vmap <leader>fp xO<Esc>0i# hongyu:<CR><Esc>k:read !git config --get user.name<CR>kJi<Del><Esc>$a on:<CR><Esc>k:read !date -R <CR><ESC>kJ$o<ESC>0i# TODO: replace this line with your comment<CR><ESC>0i=begin<Esc>gp<Esc>0a=end<CR><Esc>0a=cut<CR><CR><Esc>0i# End of hongyu:<Esc>:read !git config --get user.name<CR>kJJ<Del>k
"for shell
map <leader>fs o<ESC>0i# hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>$a on:<Esc>:read !date -R <CR><ESC>kJ$o<ESC>0i# TODO: replace this line with your comment<CR><CR><Esc>0i# End of hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>k
vmap <leader>fs xO<Esc>0i# hongyu:<CR><Esc>k:read !git config --get user.name<CR>kJi<Del><Esc>$a on:<CR><Esc>k:read !date -R <CR><ESC>kJ$o<ESC>0i# TODO: replace this line with your comment<CR><ESC>0i: INGORED UP TO << '--END-COMMENT--'<Esc>gp<Esc>0a--END-COMMENT--<CR><CR><Esc>0i# End of hongyu:<Esc>:read !git config --get user.name<CR>kJJ<Del>k
"for makefile
map <leader>fm o<ESC>0i# hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>$a on:<Esc>:read !date -R <CR><ESC>kJ$o<ESC>0i# TODO: replace this line with your comment<CR><CR><Esc>0i# End of hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>k
vmap <leader>fm xO<Esc>0i# hongyu:<CR><Esc>k:read !git config --get user.name<CR>kJi<Del><Esc>$a on:<CR><Esc>k:read !date -R <CR><ESC>kJ$o<ESC>0i# TODO: replace this line with your comment<CR><ESC>0iifdef 0<Esc>gp<Esc>0aendif<CR><CR><Esc>0i# End of hongyu:<Esc>:read !git config --get user.name<CR>kJJ<Del>k
"for xml
map <leader>fx o<ESC>0i<!-- hongyu:<Esc>:read !git config --get user.name<CR>kJ<Del>$a on:<Esc>:read !date -R <CR><ESC>kJ$o<ESC>0iTODO: replace this line with your comment<CR><Esc>0a--><CR><CR><Esc>0i<!-- End of hongyu:<Esc>:read !git config --get user.name<CR>$a --><Esc>kJ<Del>k
vmap <leader>fx xO<Esc>0i<!-- hongyu:<CR><Esc>k:read !git config --get user.name<CR>kJi<Del><Esc>$a on:<CR><Esc>k:read !date -R <CR><ESC>kJ$o<ESC>0iTODO: replace this line with your comment<Esc>gp<Esc>0a--><CR><CR><Esc>0i<!-- End of hongyu:<Esc>:read !git config --get user.name<CR>$a --><Esc>kJJ<Del>k
?
4.配置好以上脚本、恭喜你完成了
然后列出你的修改文件svn st
用vim编辑你的修改文件vim XXX.xxx(XXX文件名、xxx后缀)
然后找到你修改的地方? ctrl+v选中你修改的行
然后 按 “ .fj”(java文件是".fj"? ,xml文件是“.fx”其他的文件请直接看对应 的命令)直接添加注释
如我修改了我的java文件
? /* hongyu:hehangjun on: Mon, 08 Oct 2012 15:50:40 +0800
?* TODO: replace this line with your comment
??? static final String EXTRA_CUSTOM_WIDGET = "custom_widget";??? //这两行被注释了、这是原始代码
??? static final String SEARCH_WIDGET = "search_widget";
?*/
??????????????????? //这里将填写你修改的代码的
// End of hongyu: hehangjun
?
O(∩_∩)O谢谢大家观赏、