The scripting language is really strong.
My goal is to add my default dock function to Vim.
/****************************************************************************** * Copyright NOTICE * Copyright (c) 2014 All rights reserved *----Stay hungry Stay foolish----* * @author: Shen * @name: * @file: G:\My Source C Ode\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>inlin
e bool Updatemax (t& A, T b) {return a < b? a = B, 1:0;} /*//stl #include <map> #include <vector> #include <list> #include <stack> #include <deque> #include <queue>//*//computational Geometry #include <complex> #define x real () #define Y imag
() typedef complex<double> Point;
*/typedef long long Int64;
void Solve () {} int main () {return 0;}
Use the RUBY10 line to handle the string. It's a blast.
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 end
load ("DefaultCode.cpp")
The end of the artificial head a plus, done.
"F4 Add File Header map <F4>: Call Titledet () <cr> function addtitle () Let L = 0 let 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, '/*//stl ') let L = L + 1 | Call SetliNE (l, ' #include <map> ') let L = L + 1 | Call Setline (L, ' #include <vector> ") let L = L + 1 | Call Setline (L, ' #include <list> ") let L = L + 1 | Call Setline (L, ' #include <stack> ") let L = L + 1 | Call Setline (L, ' #include <deque> ") let L = L + 1 | Call Setline (L, ' #include <queue> ") let L = L + 1 | Call Setline (L, '/* ') let L = L + 1 | Call Setline (L, ' ") let L = L + 1 | Call Setline (L, '/*//computational Geometry ') let L = L + 1 | Call Setline (L, ' #include <complex> ") let L = L + 1 | Call Setline (L, "#define X Real ()") Let L = L + 1 | Call Setline (l, ' #define y imag () ") Let L = L + 1 | Call Setline (L, "typedef complex<double> point;") 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 | ca ll Setline (L, '} ') endfunction update last modified time and filename function updatetitle () call Setline (8, ' * @file: '. Expand ("%:p: H"). " \ ". Expand ("%:t ")) Call Setline (9, ' * @date: '. Strftime ("%y/%m/%d%h:%m ")) endfunction" Judge whether there are any copyright in the first 10 lines of code Noti Ce this word, "if not, the representative has not added author information, need to add;" If there is, then only need to update the function Titledet () Let n = 2 "default to add let line = Getline (n) Let S
tr = ' ^* COPYRIGHT notice$ ' if line =~ str call Updatetitle () return endif call AddTitle () endfunction