vim中自己主动加入凝视 加入文本信息

工欲善其事,必先利其器。在开发过程中。方便、快捷的开发环境。能提高工作效率。优美的界面能让我们心情愉悦;最重要的是,能保持我们在外行严重高深莫測的牛逼~

  假设在创建新的源程序文件时希望能自己主动产生一些凝视,比方作者、创建日期,联系方式等。能够这样做:

  编辑~/.vimrc 文件。增加代码:  

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

func SetComment()
	call setline(1,"/********************************************************") 
	call append(line("."),   "*   Copyright (C) ".strftime("%Y")." All rights reserved.")
	call append(line(".")+1, "*   ") 
	call append(line(".")+2, "*   Filename:".expand("%:t")) 
	call append(line(".")+3, "*   Author  :wang@xd")
	call append(line(".")+4, "*   Date    :".strftime("%Y-%m-%d")) 
	call append(line(".")+5, "*   Describe:") 
	call append(line(".")+6, "*")
	call append(line(".")+7, "********************************************************/") 
endfunc

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

vim中多行凝视 和 删除多行凝视
-------------------------------------------------------------------------------
1.多行凝视:
  a. 按下Ctrl + v,进入列模式;
  b. 在行首选择须要凝视的行;
  c. 按下“I”,进入插入模式;
  d. 然后输入凝视符(“//”、“#”等);
  e. 按下“Esc”键。

2.删除多行凝视:
  a. 按下Ctrl + v, 进入列模式;
  b. 选定要取消的凝视符;
  c. 按下“x”或者“d”.

原文地址:https://www.cnblogs.com/yjbjingcha/p/7281011.html