栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

vi编程文件配置教程(Linux下)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

vi编程文件配置教程(Linux下)

1.通过gedit .rmvic进入vi编程配置文件,将下面的指令复制粘贴进去保存退出就可以了

(可以根据需要修改其中的名字,邮箱等)


 "set mouse-=a
 set nu
 syntax on
 syntax enable
 colorscheme desert
 
  " TagList
 let Tlist_Show_One_File=1
 let Tlist_Exit_onlyWindow=1
 
 " WinManager
 let g:winManagerWindowLayout='FileExplorer|TagList'
 nmap wm :WMToggle
 
 " Omnicompletion
 set nocp
 filetype plugin indent on
 set completeopt=longest,menu

 " Indent
 set smartindent
 set expandtab

 " 自动缩进
 set autoindent
 set cindent
 " Tab键的宽度
 set tabstop=4
 " 统一缩进为4
 set softtabstop=4
 set shiftwidth=4

 " 将tab替换为空格
 nmap tt :%s/t/    /g

 set foldenable      " 允许折叠  
 set foldmethod=manual   " 手动折叠

 nmap s :cs find s =expand("")
 nmap g :cs find g =expand("")
 nmap c :cs find c =expand("")
 nmap t :cs find t =expand("")
 nmap e :cs find e =expand("")
 nmap f :cs find f =expand("")
 nmap i :cs find i ^=expand("")$
 nmap d :cs find d =expand("")

 autocmd BufNewFile *.[ch],*.hpp,*.cpp exec ":call SetTitle()" 
  
 "加入注释
 func SetComment()
 call setline(1,"") 
 endfunc

 "定义函数SetTitle,自动插入文件头 
 func SetTitle()
 call SetComment()
 if expand("%:e") == 'hpp' 
 call append(line(".")+10, "#ifndef _".toupper(expand("%:t:r"))."_H") 
 call append(line(".")+11, "#define _".toupper(expand("%:t:r"))."_H") 
 call append(line(".")+12, "#ifdef __cplusplus") 
 call append(line(".")+13, "extern "C"") 
 call append(line(".")+14, "{") 
 call append(line(".")+15, "#endif") 
 call append(line(".")+16, "") 
 call append(line(".")+17, "#ifdef __cplusplus") 
 call append(line(".")+18, "}") 
 call append(line(".")+19, "#endif") 
 call append(line(".")+20, "#endif //".toupper(expand("%:t:r"))."_H") 
 elseif expand("%:e") == 'h' 
 call append(line(".")+10, "#endif") 
 call append(line(".")+10, "") 
 call append(line(".")+10, "#ifndef _".toupper(expand("%:t:r"))."_H") 
 call append(line(".")+11, "#define _".toupper(expand("%:t:r"))."_H") 
 elseif &filetype == 'c' 
"  call append(line(".")+10,"#include ") 
"  call append(line(".")+10,"#include ") 
"  call append(line(".")+10,"#include ") 
 call append(line(".")+6,"#include ") 
 call append(line(".")+7,"") 
 call append(line(".")+8,"int main(int argc, char *argv[])") 
 call append(line(".")+9,"{ " ) 
 call append(line(".")+10,"" ) 
 call append(line(".")+11,"    return 0;") 
 call append(line(".")+12,"} ") 
 elseif &filetype == 'cpp' 
 call append(line(".")+10,"#include ") 
 call append(line(".")+10,"using namespace std;") 
 endif
 endfunc

"新建文件后,自动定位到文件第10行
autocmd BufNewFile * normal 10gg



set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030

新建界面格式如下

  1
  8 #include
  9 
 10 int main(int argc, char *argv[])
 11 {
 12 
 13     return 0;
 14 }
 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/748496.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号