时间:2021-05-22
脚本语言真是太强了。
我的目的是把我的默认代码头功能加到Vim里面。
/******************************************************************************* COPYRIGHT NOTICE* Copyright (c) 2014 All rights reserved* ----Stay Hungry Stay Foolish----** @author : Shen* @name :* @file : G:\My Source Code\DefaultCode.cpp* @date : 2014/06/14 02:44* @algorithm :******************************************************************************///#pragma GCC optimize ("O2")//#pragma comment(linker, "/STACK:1024000000,1024000000")#include <bits/stdc++.h>#include <cmath>#include <cstdio>#include <string>#include <cstring>#include <iomanip>#include <iostream>#include <algorithm>using namespace std;template<class T>inline bool updateMin(T& a, T b){ return a > b ? a = b, 1: 0; }template<class T>inline bool updateMax(T& a, T b){ return a < b ? a = b, 1: 0; }typedef long long int64;void solve(){}int main(){ return 0;}用Ruby10行就搞定了字符串的处理。简直爽爆了。
def load( path ) File.foreach(path) do |line| line["\n"] = "" str = "let l = l + 1 | call setline(l, \'#{line}\')" File.open("s.txt", "a") do |f| f << "#{str}\n" end endendload("DefaultCode.cpp")最后人工把头尾一加,搞定了。
"F4 添加文件头map <F4> :call TitleDet()<cr>function AddTitle()let l = 0let l = l + 1 | call setline(l, '/******************************************************************************')let l = l + 1 | call setline(l, '* COPYRIGHT NOTICE')let l = l + 1 | call setline(l, '* Copyright (c) 2014 All rights reserved')let l = l + 1 | call setline(l, '* ----Stay Hungry Stay Foolish----')let l = l + 1 | call setline(l, '*')let l = l + 1 | call setline(l, '* @author : Shen')let l = l + 1 | call setline(l, '* @name :')let l = l + 1 | call setline(l, '* @file : '.expand("%:p:h")."\\".expand("%:t"))let l = l + 1 | call setline(l, '* @date : '.strftime("%Y/%m/%d %H:%M"))let l = l + 1 | call setline(l, '* @algorithm :')let l = l + 1 | call setline(l, '******************************************************************************/')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, '//#pragma GCC optimize ("O2")')let l = l + 1 | call setline(l, '//#pragma comment(linker, "/STACK:1024000000,1024000000")')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, '#include <bits/stdc++.h>')let l = l + 1 | call setline(l, '#include <cmath>')let l = l + 1 | call setline(l, '#include <cstdio>')let l = l + 1 | call setline(l, '#include <string>')let l = l + 1 | call setline(l, '#include <cstring>')let l = l + 1 | call setline(l, '#include <iomanip>')let l = l + 1 | call setline(l, '#include <iostream>')let l = l + 1 | call setline(l, '#include <algorithm>')let l = l + 1 | call setline(l, 'using namespace std;')let l = l + 1 | call setline(l, 'template<class T>inline bool updateMin(T& a, T b){ return a > b ? a = b, 1: 0; }')let l = l + 1 | call setline(l, 'template<class T>inline bool updateMax(T& a, T b){ return a < b ? a = b, 1: 0; }')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, 'typedef long long int64;')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, 'void solve()')let l = l + 1 | call setline(l, '{')let l = l + 1 | call setline(l, ' ')let l = l + 1 | call setline(l, '}')let l = l + 1 | call setline(l, '')let l = l + 1 | call setline(l, 'int main()')let l = l + 1 | call setline(l, '{')let l = l + 1 | call setline(l, ' ')let l = l + 1 | call setline(l, ' return 0;')let l = l + 1 | call setline(l, '}')endfunction"更新最近修改时间和文件名function UpdateTitle() call setline(8, '* @file : '.expand("%:p:h")."\\".expand("%:t")) call setline(9, '* @date : '.strftime("%Y/%m/%d %H:%M"))endfunction"判断前10行代码里面,是否有COPYRIGHT NOTICE这个单词,"如果没有的话,代表没有添加过作者信息,需要新添加;"如果有的话,那么只需要更新即可function TitleDet() let n = 2 "默认为添加 let line = getline(n) let str = '^* COPYRIGHT NOTICE$' if line =~ str call UpdateTitle() return endif call AddTitle()endfunction声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
在开始编写插件之前,你需要确认Vim是否支持Ruby,通过以下命令来判别:$vim--version|grep+ruby如果输出为空,则表示你当前的vim不支持
1、vim/usr/local/apache2/conf/extra/httpd-vhosts.conf添加或修改为:复制代码代码如下:ErrorLog"log
这篇文章主要介绍了我是如何把rubygemcontracts.ruby速度提升10倍的。contracts.ruby在我项目里用来添加代码合约(codecont
复制代码代码如下://////生成二维码//////生成二维码路径///生成的内容///二维码宽///二维码高///需生成的Logo图片///privateBi
想看前面整理的canvas常用API的同学可以点下面:canvas学习之API整理笔记(一)canvas学习之API整理笔记(二)本系列文章涉及的所有代码都将上