vim自動添加頭文件


每次建立 .c文件 總要有一大堆的頭文件要放進去。如下代碼實現了自動化頭文件:

autocmd BufNewFile *.c exec ":call AddTitleForShell()"
function AddTitleForShell()
call append(0,"//Author:kunshanpipixia")
call append(1,"#include <stdio.h>")
call append(2,"#include <stdlib.h>")
call append(3,"#include <string.h>")
call append(4,"#include <pthread.h>")
call append(5,"#include <unistd.h>")
endfunction

只需將此代碼粘貼至vimrc文件中即可。

下次再vim xxx.c命令時,自動添加你需要的頭文件,是不是很方便?!!!!

 

 如下為最終效果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM