关于vimplus安装以及如何设置自定义头以及开发者信息

安装vimplus

//第一步先下载
git clone https://github.com/chxuan/vimplus.git ~/.vimplus
//第二步进入目录
cd ~/.vimplus
//第三步执行命令(直接等待完成)
./install.sh  //注意此处不需要加sudo

PS:编译到最后他会让你选择Python版本[2/3],这个选择2或者3都可以

编译YouCompleteMe

1、YouCompleteMe是一个很强大的代码自动补全的插件
2、安装完毕后进入此目录**/home/你的用户名/.vim/plugged/YouCompleteMe**
3、然后你就能看见一个install.py
4、输入 python3 install.py --clang-completer进行编译(注意Python3的版本很高导致编译出错,使用python install.py --clang-completer默认用python2来编译)

5,等待完成100%即可
在这里插入图片描述

设置自定义头信息

1、以上我们安装好以后进入/home/你的用户名/.vim/plugged/prepare-code/autoload/prepare这个目录

在这里插入图片描述

2、我们可以看到有两个文件prepare.vim和util.vim
3、我们打开prepare.vim

在最后加上以下代码
在这里插入图片描述

" 头信息生成作者信息生成
function! s:gen_information(suffix)
    let axfilename = expand("%t")
    let cxxheadername = substitute(axfilename,'\.\w\+$','','') "这个是去掉拓展名
    if a:suffix == 'sh' || a:suffix == 'py'        
        call setline(1, "##########################################################################")         
        call append(line("."), "# File Name: ".axfilename)         
        call append(line(".")+1, "# Name: ")         
        call append(line(".")+2, "# mail: xxx@xxx.com")         
        call append(line(".")+3, "# Created Time: ".strftime("%c"))         
        call append(line(".")+4, "#########################################################################")         
        call append(line(".")+5, "")
    elseif a:suffix == 'h' || a:suffix == 'hpp'
        call setline(1, "/*************************************************************************")         
        call append(line("."), "*File Name: ".axfilename)         
        call append(line(".")+1, "*Name: ")         
        call append(line(".")+2, "*mail: xxx@xxx.com")         
        call append(line(".")+3, "*Created Time: ".strftime("%c"))         
        call append(line(".")+4, " ************************************************************************/")         
        call append(line(".")+5, "#ifndef _".toupper(cxxheadername)."_H")    
        call append(line(".")+6, "#define _".toupper(cxxheadername)."_H")    
        call append(line(".")+7, "#include <iostream>")    
        call append(line(".")+8, "#include <map>")    
        call append(line(".")+9, "#include <vector>")    
        call append(line(".")+10, "#include <cstdlib>")    
        call append(line(".")+11, "")    
        call append(line(".")+12, "#endif")    
    elseif a:suffix == 'c' || a:suffix == 'cpp' || a:suffix == 'cxx' || a:suffix == 'cc' 
        call setline(1, "/*************************************************************************")         
        call append(line("."), "*File Name: ".axfilename)         
        call append(line(".")+1, "*Name: ")         
        call append(line(".")+2, "*mail: xxx@xxx.com")         
        call append(line(".")+3, "*Created Time: ".strftime("%c"))         
        call append(line(".")+4, " ************************************************************************/")         
        call append(line(".")+5, "")    
    endif    
endfunction
    
//elseif a:suffix == 'h' || a:suffix == 'hpp'
//elseif a:suffix == 'c' || a:suffix == 'cpp' || a:suffix == 'cxx' || a::suffix == 'cc' 下面的call可以自由发挥
具体操作是
call append(line(".")+行号, "这里面写内容(例如头文件包含)")
4、在最上面找到function! prepare#prepare#gen_prepare_code()图一
  • 找到let suffix = prepare#util#get_current_file_suffix()在此下面加上一行代码
 call <sid>gen_information(suffix) "这个就是刚刚我们设置的那个函数
  • 然后就得到了以上图一的结果
  • 然后我们按键盘的esc键,然后按shift+冒号输入wq,退出保存
5、打开util.vim
  • 找到下图中的代码
    在这里插入图片描述
function! prepare#util#write_text_at_current_row(text)
    execute "normal i" . a:text
endfunction
6、将其加入一行得到
function! prepare#util#write_text_at_current_row(text)
    execute "normal G"
    execute "normal i" . a:text
endfunction

如图:
在这里插入图片描述 - 然后我们按键盘的esc键,然后按shift+冒号输入wq,退出保存即可

7、我们还需要做一件事
  • 进入/home/用户名/.vim/plugged/prepare-code/snippet目录下
  • 然后进入编辑snippet.h里面的文件,将其情空
8、我们测试来看看
  • 这是CPP文件创建后的效果
    在这里插入图片描述
  • 这是.h文件创建的效果

在这里插入图片描述

  • 这是py创建的效果
    在这里插入图片描述

制作不易,请大家点个赞哈,关注关注,谢谢

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值