vim配置文件模版

vim函数实现


function AddTitle()
call setline(1,"at :call AddTitle()

新建test.php即可看到以下内容

或者使用第二种方式生成

vim插件实现

这里使用coc-template实现。
先安装coc.nvim。github地址,coc.nvim安装

安装coc-template

// 安装coc-templete命令
npm i coc-template

// vim下安装coc-templete插件
:CocInstall coc-template

查看插件所在的项目目录我本地是~/.config/coc/extensions/node_modules/coc-template。以下目录结构

.
├── README.md
├── lib
│   └── index.js
├── package.json
└── templates
    ├── =template=.bash
    ├── =template=.c
    ├── =template=.cmake
    ├── =template=.coffee
    ├── =template=.css
    ├── =template=.dart
    ├── =template=.f
    ├── =template=.f90
    ├── =template=.go
    ├── =template=.h
    ├── =template=.hs
    ├── =template=.html
    ├── =template=.humans.txt
    ├── =template=.java
    ├── =template=.jl
    ├── =template=.js
    ├── =template=.jsp
    ├── =template=.jsx
    ├── =template=.lhs
    ├── =template=.lua
    ├── =template=.ml
    ├── =template=.php
    ├── =template=.pl
    ├── =template=.pls
    ├── =template=.pm
    ├── =template=.pro
    ├── =template=.py
    ├── =template=.rb
    ├── =template=.robots.txt
    ├── =template=.rs
    ├── =template=.sh
    ├── =template=.sol
    ├── =template=.sql
    ├── =template=.tex
    ├── =template=.txt
    ├── =template=.xml
    ├── =template=.xsl
    ├── =template=.zcml
    └── =template=Makefile

templates文件夹下是模版文件可以根据需要自行修改添加。lib是脚本文件。可以在里面查看预定义的变量。修改=template=.php文件

%USER%等变量可在/lib/index.js里面查看定义

nmap t :CocCommand template.templateTop

新建test.php文件 使用t快捷键效果可上面的是一样的

你可能感兴趣的:(vim配置文件模版)