1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
Amir Salihefendic
2018-03-31 11:56:26 -03:00
parent 7c643a2d9c
commit 02572caa95
84 changed files with 4588 additions and 1749 deletions

View File

@ -100,4 +100,11 @@ snippet todo "TODO comment" bw
`!p snip.rv=get_comment_format()[0]` ${2:TODO}: $0${3: <${4:`!v strftime('%d-%m-%y')`}${5:, `!v g:snips_author`}>} `!p snip.rv=get_comment_format()[2]`
endsnippet
##########
# Misc #
##########
snippet uuid "Random UUID" w
`!p if not snip.c: import uuid; snip.rv = uuid.uuid4()`
endsnippet
# vim:ft=snippets:

View File

@ -104,7 +104,7 @@ snippet fnc "Basic c++ doxygen function template" b
*/
${1:ReturnType} ${2:FunctionName}(${3:param})
{
${0:FunctionBody}
${0:FunctionBody}
}
endsnippet
# vim:ft=snippets:

View File

@ -0,0 +1,733 @@
###########################################################################
# PLSQL SNIPPETS #
###########################################################################
global !p
# Import package
import datetime
# Return the doc string for PLSQL script
def docstring_plsql(params):
comment = ""
if params:
comment = "/** Parameters\n"
# Split the arguments
args = [arg.strip() for arg in params.split(',')]
for arg in args:
comment += "* {0:30} : \n".format(arg.split(' ')[0].upper())
comment += "*/\n"
# Return the comment string
return comment
def hdr_params(params, level=0, gap=" "):
line = level * gap + "-- -----------------------------------------------"
comment = line
if params:
# Split the arguments
args = [arg.strip() for arg in params.split(',')]
for arg in args:
comment += "\n" + level * gap + "-- {0:20} : ".format(arg.split(' ')[0].upper())
# comment += line
# Return the comment string
return comment
def dyear():
""" Returns the current Year in YYYY format
"""
now = datetime.datetime.now()
rv=now.year
return rv
def today():
""" Returns the current Date in DD-MON-YYYY format
"""
now = datetime.datetime.now()
rv=now.strftime("%d-%b-%Y")
return rv
def param(var):
""" Returns the string name wrapped value """
return "'" + var + " : ' || "
endglobal
########################################
# SQL Snippets #
########################################
snippet doc "Document comment"
/*
* ${0: comment ...}
*/
endsnippet
snippet hdr "Header Documentation"
-- #############################################################################
-- # Copyright (c) `!p snip.rv = dyear()` ${1:company}
-- # All rights reserved
-- #
-- ############################################################################
-- # Application : ${2:schema}
-- # File Name: : ${3:`!p snip.rv=snip.fn`}
-- # Type : Table
-- # Exec Method : PL/SQL File
-- # Description : This script ${5:create} under the schema $2
-- #
-- # Change History
-- # -----------------------------------------------------------------------
-- # Version Date Author Remarks
-- # ======= =========== ================ ============================
-- # 1.0 `!p snip.rv = today()` Amit Maindola Initial Version
-- #############################################################################
endsnippet
snippet pkggbl "Package Global variables"
-- Declare Global Variables
g_sysdate DATE := SYSDATE;
g_delimiter VARCHAR2( 30 ) := ' ';
g_err_length_limit NUMBER := 1500;
g_package_name CONSTANT VARCHAR2(30) := '${0}';
g_proc_name VARCHAR2(100) := NULL;
excp_custom EXCEPTION;
-- Declare User Global Types
endsnippet
snippet flushca "Flush Cache"
ALTER SYSTEM FLUSH BUFFER_CACHE;
endsnippet
snippet flushsp "Flush Shared Pool"
ALTER SYSTEM FLUSH SHARED_POOL;
endsnippet
snippet err
show errors;
endsnippet
snippet sel "Select statement"
SELECT ${0:*} FROM ${1} WHERE 1 = 1;
endsnippet
snippet selc "Select statement"
SELECT COUNT(1) FROM ${1} WHERE ${0};
endsnippet
snippet wrn "Where ROWNNUM"
WHERE ROWNUM <= 10 ${0:AND}
endsnippet
snippet arn "AND ROWNNUM"
AND ROWNUM <= 10 ${0:;}
endsnippet
snippet ppram "Retuns param in wrapped format"
||`!p snip.rv = param(t[1].upper())`$1 $0
endsnippet
snippet dbo "Show output "
DBMS_OUTPUT.put_line('${0}');
endsnippet
snippet dbop "Show Parameter output "
DBMS_OUTPUT.put_line(`!p snip.rv = param(t[1].upper())`$1 $0);
endsnippet
snippet dbl "Log message in Log Table, Change procedure as defined by you"
DEBUG_LOG_PKG.WRITE_LOG(${1:'Test'},${2:$1} ,$0 );
endsnippet
snippet plog "Print Log output "
printlog(`!p snip.rv = param(t[1].upper())`$1 $0);
endsnippet
snippet dut "DBMS_OUTPUT.put_line"
DBMS_UTILITY.get_time;
endsnippet
snippet bc "Bulk collect into"
bulk collect into ${0}
endsnippet
snippet ei "Execute Immediate"
EXECUTE IMMEDIATE '${0:statement}' ;
endsnippet
snippet eitt "Execute Immediate TRUNCATE Table"
EXECUTE IMMEDIATE( 'TRUNCATE TABLE ${0:table}');
endsnippet
snippet eitp "Execute Immediate ALTER Table Truncate partition"
EXECUTE IMMEDIATE( 'ALTER TABLE ${1:table} TRUNCATE PARTITION ${0:partition}');
endsnippet
snippet prmpt "Prompt message"
PROMPT ${1:Creating }...
endsnippet
snippet crseq "Create Sequence"
DROP SEQUENCE ${1:schema}.${2:name}_s;
CREATE SEQUENCE $1.$2_s
START WITH ${3:1}
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;
endsnippet
snippet crsyn "Create Synonym"
CREATE OR REPLACE SYNONYM ${1:schema}.${2:name} FOR ${3:target}.${0};
endsnippet
snippet crind "Create Index"
DROP INDEX $1.$4;
CREATE INDEX $1.${4:$2_${5}}
ON ${1:schema}.${2:table}(${3}) ${6:TABLESPACE ${0} };
endsnippet
########################################
# Table Operation #
########################################
snippet drtab "Drop Table"
DROP TABLE ${1:schema}.${2:name} CASCADE CONSTRAINTS ${3:PURGE};
endsnippet
snippet crtab "Create Table"
DROP TABLE ${1:schema}.${2:name} CASCADE CONSTRAINTS PURGE;
CREATE TABLE $1.$2
(
${0}
)
${3:TABLESPACE ${4}}
;
endsnippet
snippet ccol "Add VARCHAR2 column to table"
${1:,} ${2:name} VARCHAR2(${0:100})
endsnippet
snippet dcol "Add DATE column to table"
${1:,} ${0:name} DATE
endsnippet
snippet ncol "Add NUMBER column to table"
${1:,} ${0:name} NUMBER
endsnippet
snippet at "Alter Table"
ALTER TABLE ${1:table} ${0}
endsnippet
#########################################
# Declare Types and local variable #
#########################################
snippet tr "Type record"
TYPE t_${1:rec} IS RECORD (${0:/* columns */} );
endsnippet
snippet tt "Type Table"
TYPE t_${1:tbl} IS TABLE OF ${0:table_name}%ROWTYPE INDEX BY BINARY_INTEGER;
endsnippet
snippet tc "Type Cursor"
TYPE t_${1:tbl} IS TABLE OF ${0:cur}%ROWTYPE INDEX BY BINARY_INTEGER;
endsnippet
snippet pn
p_${1} ${2:IN} NUMBER ${3:DEFAULT ${0:NULL}}
endsnippet
snippet pd
p_${1} ${2:IN} DATE ${3:DEFAULT ${0:SYSDATE}}
endsnippet
snippet pc
P_${1} ${2:IN} VARCHAR2 ${3:DEFAULT ${0:NULL}}
endsnippet
snippet ln
l_${1} NUMBER ${2: := ${3} };
endsnippet
snippet ld
l_${1} DATE ${2: := ${3} };
endsnippet
snippet lc
l_${1} VARCHAR2(${2:100}) ${3: := ${4} };
endsnippet
snippet gn
g_${1} NUMBER ${2: := ${3:10} };
endsnippet
snippet gd
g_${1} DATE ${2: := ${3:SYSDATE} };
endsnippet
snippet gc
g_${1} VARCHAR2(${2:100}) ${3: := ${4} };
endsnippet
snippet ltbl
l_tbl_${1} ${0};
endsnippet
snippet lrec
l_rec_${1} ${0};
endsnippet
#########################################
# Condition, Loops #
#########################################
snippet if "If Condition"
IF(${1}) THEN
${0};
END IF;
endsnippet
snippet ife "IF-Else Condition"
IF(${1}) THEN
${2};
ELSIF
${0};
END IF;
endsnippet
snippet els "Else Condition"
ELSIF ${1:condition} THEN
${0};
endsnippet
snippet case "Case statement"
CASE WHEN (${1}) THEN
${2}
WHEN (${3}) THEN
${4}
${0:ELSE}
END
endsnippet
snippet while "While Loop"
WHILE ${1:a} ${2:condition} ${3:b} LOOP
${0};
END LOOP;
endsnippet
snippet fori "For Loop"
FOR ${1:indx} in ${2:1}..${3:10} LOOP
${4};
END LOOP;
endsnippet
snippet fort "Table For Loop"
FOR ${1:indx} in 1..${2:ttb}.count LOOP
${0};
END LOOP;
endsnippet
snippet loop "Loop statement"
LOOP
${0};
END LOOP;
endsnippet
snippet fora "For All Loop"
IF ( ${1:ttbl}.COUNT > 0 ) THEN
BEGIN
FORALL ${2:indx} IN 1 .. $1.COUNT
-- Insert/Update
${0}
EXCEPTION --Exception Block
WHEN OTHERS THEN
l_errmsg := 'Error while Bulk updating, Error : ' || SQLERRM;
RAISE excp_custom;
END;
END IF;
endsnippet
snippet forc "For Cursor Loop"
FOR $1_rec IN ${1:cur} ${2:(${3:param})}
LOOP
${0}
END LOOP; -- End $1
endsnippet
#########################################
# Cursor Operations #
#########################################
snippet dcur "Cursor declaration"
CURSOR ${1:cur} IS
SELECT ${0}
FROM $1
WHERE 1 = 1;
endsnippet
snippet copen "Open Cursor"
OPEN ${1:cursor} ${2:( ${3:param} )};
FETCH $1
INTO ${4:record};
${0}
IF ( $1 %NOTFOUND ) THEN
CLOSE $1;
l_errmsg := 'No records fetched in cursor : $1.';
RAISE excp_custom;
END IF;
CLOSE $1;
endsnippet
snippet copenbc "Open Cursor Bulk collect"
OPEN ${1:cursor} ${2:( ${3:param} )};
FETCH $1
BULK COLLECT INTO ${4:ttbl};
CLOSE $1;
IF ( $4.count = 0 ) THEN
l_errmsg := 'No records fetched in cursor : $1.';
RAISE excp_custom;{0}
END IF;
endsnippet
#########################################
# BEGIN/DECLARE Blocks #
#########################################
snippet decl "Declare Begin block"
DECLARE
${1}
BEGIN
${0:null}
EXCEPTION --Exception Block
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('No Data Found');
WHEN OTHERS THEN
dbms_output.put_line('Error while . Error : '||sqlerrm);
END;
endsnippet
snippet begin "Begin block"
BEGIN
${0}
EXCEPTION --Exception Block
WHEN NO_DATA_FOUND THEN
printlog('No Data Found');
WHEN OTHERS THEN
printlog('Error while . Error : '||sqlerrm);
END;
endsnippet
snippet excp "Exception Block"
EXCEPTION --Exception Block
${0}
WHEN OTHERS THEN
${1};
END;
endsnippet
snippet rae "Raise Application Error"
RAISE_APPLICATION_ERROR(${1:-20000},${0:''});
endsnippet
#########################################
# Procedure/Function calling #
#########################################
snippet crjob "Submit DBMS Job"
-- Submit the job to get the output
BEGIN
DECLARE
vjob INTEGER;
BEGIN
DBMS_JOB.submit( vjob, '${1:procedure}${0:('''')};', SYSDATE );
DBMS_OUTPUT.put_line( 'Job id : ' || vjob );
COMMIT;
END;
END;
endsnippet
snippet whilejob "Submit DBMS Job with While Loop"
-- Submit the job to get the output
BEGIN
DECLARE
vjob INTEGER;
BEGIN
DBMS_JOB.submit ( vjob , '
DECLARE
l_start_date DATE := ''${1:01-Jan-2017}'';
BEGIN
WHILE l_start_date < ''${2:01-Jan-2017}''
LOOP
${3:Procedure}${0:( to_char(l_start_date,''YYYYMMDD'') )};
l_start_date := TRUNC( l_start_date + 1 );
END LOOP;
EXCEPTION --Exception Block
WHEN OTHERS THEN
DBMS_OUTPUT.put_line( ''Error while . Error : '' || SQLERRM );
END;
'
, SYSDATE
);
DBMS_OUTPUT.put_line( 'Job id : ' || vjob );
COMMIT;
END;
END;
endsnippet
#########################################
# Function creation scripts #
#########################################
snippet crprintlog "Create Printlog Procedure"
------------------------------------------------------------------------------------------------
-- PROCEDURE : PRINTLOG
-- Description : This procedure is used to print log messages in Log file, Table and Console
------------------------------------------------------------------------------------------------
PROCEDURE printlog (p_message IN VARCHAR2)
IS
l_errmsg VARCHAR2 (10000);
BEGIN
l_errmsg := SUBSTR ( p_message, 1, g_err_length_limit);
fnd_file.put_line ( fnd_file.LOG, l_errmsg); -- Debug log file
DBMS_OUTPUT.put_line (l_errmsg); -- Console output
DEBUG_LOG_PKG.WRITE_LOG(g_package_name,g_proc_name,p_message); -- Debug table
END printlog;
endsnippet
snippet crgeterr "Create get_errmsg function"
-- Form the error message for when others
FUNCTION get_errmsg( p_message IN VARCHAR2 DEFAULT NULL )
RETURN VARCHAR2
IS
BEGIN
RETURN 'Error occured in ' || g_package_name || '.' || g_proc_name || '. ' || NVL( p_message, '' ) || ' Error : ' || SQLERRM;
EXCEPTION --Exception Block
WHEN OTHERS THEN
printlog( 'Error while forming messgage. Error : ' || SQLERRM );
RETURN NULL;
END;
endsnippet
snippet crpksfunc "Create package specification function"
------------------------------------------------------------------------------------------------
-- Function : `!p snip.rv = t[1].upper()`
-- Description : This Function will ${4:description}.
`!p snip.rv=hdr_params(t[3]) `
------------------------------------------------------------------------------------------------
FUNCTION ${1:func} ${2:(${3:params})}
RETURN ${0};
endsnippet
snippet crpksproc "Create package specification procedure"
------------------------------------------------------------------------------------------------
-- PROCEDURE : `!p snip.rv = t[1].upper()`
-- Description : This Procedure will ${4:description}.
`!p snip.rv=hdr_params(t[3],0) `
------------------------------------------------------------------------------------------------
PROCEDURE ${1:proc} ${2:(${3:params})} ;
endsnippet
snippet crpkbfunc "Create package body function"
------------------------------------------------------------------------------------------------
-- Function : `!p snip.rv = t[1].upper()`
-- Description : This Function will ${8:description}.
`!p snip.rv=hdr_params(t[3],2) `
------------------------------------------------------------------------------------------------
FUNCTION ${1:func} ${2:(${3:params})}
RETURN ${4}
IS
-- Declare Cursors
-- Declare Variables
${5:l_} $4 ${6:( ${7:length} )};
BEGIN
-- Initialize
g_proc_name := '`!p snip.rv = t[1].upper()`';
${0}
-- Return value
RETURN $5 ;
EXCEPTION
WHEN OTHERS
THEN
RETURN NULL;
END $1;
endsnippet
snippet crpkbproc "Create package body procedure"
------------------------------------------------------------------------------------------------
-- PROCEDURE : `!p snip.rv = t[1].upper()`
-- Description : This Procedure will ${4:description}.
`!p snip.rv=hdr_params(t[3]) `
------------------------------------------------------------------------------------------------
PROCEDURE ${1:proc} ${2:(${3:params})}
IS
-- Declare cursors
-- Declare Out and exception variables
l_errmsg VARCHAR2( 10000 ) := null;
excp_skip EXCEPTION;
-- Declare Varibales
BEGIN
-- Initializing out parameters
g_proc_name := '`!p snip.rv = t[1].upper()`';
${0}
EXCEPTION -- Exception block of Procedure
WHEN excp_custom THEN
ROLLBACK;
printlog( l_errmsg );
WHEN OTHERS THEN
ROLLBACK;
l_errmsg := get_errmsg;
printlog( l_errmsg );
END $1;
endsnippet
snippet crpks "Create Package specification"
CREATE OR REPLACE PACKAGE ${1}.${2}
AS
-- #############################################################################
-- # Copyright (c) `!p snip.rv = dyear()` ${3}
-- # All rights reserved
-- #
-- ############################################################################
-- #
-- # Application : $1
-- # File Name: : `!p snip.rv = t[2].upper()`.pks
-- # Exec Method : PL/SQL Stored - Procedure
-- # Description : Package used for ${4}
-- #
-- # Change History
-- # -----------------------------------------------------------------------
-- # Version Date Author Remarks
-- # ======= =========== ============= ============================
-- # 1.0 `!p snip.rv = today()` Amit Maindola Initial Version
-- #
-- #
-- ############################################################################
${0}
END $2;
/
SHOW ERROR
/
endsnippet
snippet crpkb "Create package body"
CREATE OR REPLACE PACKAGE BODY ${1}.${2}
IS
-- #############################################################################
-- # Copyright (c) `!p snip.rv = dyear()` ${3}
-- # All rights reserved
-- #
-- ############################################################################
-- #
-- # Application : $1
-- # File Name: : `!p snip.rv = t[2].upper()`.pkb
-- # Exec Method : PL/SQL Stored - Procedure
-- # Description : Package used for ${4}
-- #
-- # Change History
-- # -----------------------------------------------------------------------
-- # Version Date Author Remarks
-- # ======= =========== ============= ============================
-- # 1.0 `!p snip.rv = today()` Amit Maindola Initial Version
-- #
-- #
-- ############################################################################
-- Declare Global Variables
g_sysdate DATE := SYSDATE;
g_delimiter VARCHAR2( 30 ) := ' ';
g_err_length_limit NUMBER := 1500;
g_package_name CONSTANT VARCHAR2(30) := '`!p snip.rv = t[2].upper()`';
g_proc_name VARCHAR2(100) := NULL;
excp_custom EXCEPTION;
-- Declare User Global Types
------------------------------------------------------------------------------------------------
-- PROCEDURE : PRINTLOG
-- Description : This procedure is used to print log messages
------------------------------------------------------------------------------------------------
PROCEDURE printlog( p_message IN VARCHAR2 )
IS
BEGIN
DBMS_OUTPUT.PUT_LINE( p_message );
DEBUG_LOG_PKG.WRITE_LOG(g_package_name,g_proc_name,p_message);
END printlog;
-- Form the error message for when others
FUNCTION get_errmsg( p_message IN VARCHAR2 DEFAULT NULL )
RETURN VARCHAR2
IS
BEGIN
RETURN 'Error occured in ' || g_package_name || '.' || g_proc_name || '. ' || NVL( p_message, '' ) || ' Error : ' || SQLERRM;
EXCEPTION --Exception Block
WHEN OTHERS THEN
printlog( 'Error while forming messgage. Error : ' || SQLERRM );
RETURN NULL;
END;
END $2;
/
SHOW ERROR
/
endsnippet
snippet crproc "Create procedure"
CREATE OR REPLACE PROCEDURE ${1:schema}.${2:name} ${3:( ${4:prams} )}
-- #############################################################################
-- # Copyright (c) `!p snip.rv = dyear()` ${5}
-- # All rights reserved
-- #
-- ############################################################################
-- #
-- # Application : $1
-- # File Name: : `!p snip.rv = t[2].upper()`.prc
-- # Exec Method : PL/SQL Stored - Procedure
-- # Description : Package used for ${6}
-- #
-- # Change History
-- # -----------------------------------------------------------------------
-- # Version Date Author Remarks
-- # ======= =========== ============= ============================
-- # 1.0 `!p snip.rv = today()` Amit Maindola Initial Version
-- #
-- #
-- ############################################################################
is
g_proc_name VARCHAR2(30) := '`!p snip.rv = t[2].upper()`';
l_errmsg VARCHAR2( 10000 ) := null;
excp_custom EXCEPTION;
-- Declare cursors
-- Declare Varibales
BEGIN
-- Initializing out parameters
${0}
EXCEPTION -- Exception block of Procedure
WHEN excp_custom THEN
ROLLBACK;
DEBUG_LOG_PKG.WRITE_LOG(g_proc_name,g_proc_name ,l_errmsg );
WHEN OTHERS THEN
ROLLBACK;
l_errmsg := 'Exception in procedure. '||SQLERRM;
DEBUG_LOG_PKG.WRITE_LOG(g_proc_name,g_proc_name ,l_errmsg );
END $2;
endsnippet

View File

@ -29,7 +29,7 @@ Return From Keyword ${1:${optional return value}}
endsnippet
snippet rfki "Return From Keyword If"
Return From Keyword If ${1:${condition}} ${2:${optional return value}}
Return From Keyword If '\${${1:rc}}' != '${2:abc}' ${3:${optional return value}}
endsnippet
snippet rk "Run Keyword"
@ -54,7 +54,7 @@ Run Keyword And Return ${1:${kw}} ${2:${args}}
endsnippet
snippet rkari "Run Keyword And Return If"
Run Keyword And Return If ${1:{condition}} ${2:${kw}} ${3:${args}}
Run Keyword And Return If '\${${1:rc}}' != '${2:abc}' ${3:${kw}} ${4:${args}}
endsnippet
snippet rkars "Run Keyword And Return Status"
@ -62,9 +62,12 @@ snippet rkars "Run Keyword And Return Status"
endsnippet
snippet rki "Run Keyword If"
Run Keyword If ${1:${rc} < 0} ${2:${VISUAL:Some keyword returning a value}}
... ELSE IF ${3:'${str}' == 'abc'} ${4:Another keyword}
... ELSE ${5:Final keyword}
Run Keyword If '\${${1:rc}}' != '${2:abc}'
... ${3:${VISUAL:Some keyword returning a value}}
... ELSE IF '\${${4:str}}' != '${5:def}'
... ${6:Another keyword}
... ELSE
... ${7:Final keyword}
endsnippet
snippet rkiactf "Run Keyword If Any Critical Tests Failed"
@ -102,7 +105,7 @@ Run Keywords
endsnippet
snippet rku "Run Keyword Unless"
Run Keyword Unless ${1:${condition}} ${2:${kw}} ${3:${args}}
Run Keyword Unless '\${${1:rc}}' != '${2:abc}' ${3:${kw}} ${4:${args}}
endsnippet
snippet sgv "Set Global Variable"
@ -130,7 +133,9 @@ snippet sv "Set Variable"
endsnippet
snippet svi "Set Variable If"
\${${1:var}}= Set Variable If ${2:${condition}} ${3:${value true}} ${4:${value false}}
\${${1:var}}= Set Variable If '\${${2:rc}}' != '${3:abc}'
`!p snip.rv = '...' + ' ' * (len(t[1]) + 23)` ${4:${value true}}
`!p snip.rv = '...' + ' ' * (len(t[1]) + 23)` ${5:${value false}}
endsnippet
snippet wuks "Wait Until Keyword Succeeds"

View File

@ -113,28 +113,28 @@ snippet it "Individual item" b
endsnippet
snippet part "Part" b
\part{${1:part name}}
\part{${1:part name}}%
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
$0
endsnippet
snippet cha "Chapter" b
\chapter{${1:chapter name}}
\chapter{${1:chapter name}}%
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
$0
endsnippet
snippet sec "Section" b
\section{${1:section name}}
\section{${1:section name}}%
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
$0
endsnippet
snippet sec* "Section" b
\section*{${1:section name}}
\section*{${1:section name}}%
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
@ -142,42 +142,42 @@ endsnippet
snippet sub "Subsection" b
\subsection{${1:subsection name}}
\subsection{${1:subsection name}}%
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
$0
endsnippet
snippet sub* "Subsection" b
\subsection*{${1:subsection name}}
\subsection*{${1:subsection name}}%
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
endsnippet
snippet ssub "Subsubsection" b
\subsubsection{${1:subsubsection name}}
\subsubsection{${1:subsubsection name}}%
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
$0
endsnippet
snippet ssub* "Subsubsection" b
\subsubsection*{${1:subsubsection name}}
\subsubsection*{${1:subsubsection name}}%
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
endsnippet
snippet par "Paragraph" b
\paragraph{${1:paragraph name}}
\paragraph{${1:paragraph name}}%
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
$0
endsnippet
snippet subp "Subparagraph" b
\subparagraph{${1:subparagraph name}}
\subparagraph{${1:subparagraph name}}%
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
$0

View File

@ -200,10 +200,12 @@ snippet lld
# snippets exception
snippet try
try {
}catch(${1}) {
}
snippet af auto function
auto ${1:name}(${2}) -> ${3:void}
{
${0}
};

View File

@ -1,19 +1,19 @@
# Snippets for
# Snippets for
# Authored by Trevor Sullivan <trevor@trevorsullivan.net>
# PowerShell Class
snippet class
class {
[string] ${0:FirstName}
[string] ${1:FirstName}
}
# PowerShell Advanced Function
# PowerShell Advanced Function
snippet function
function {0:name} {
function ${1:name} {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $Param1
[string] ${2:Param}
)
begin {
@ -29,30 +29,74 @@ snippet function
# PowerShell Splatting
snippet splatting
$Params = @{
${0:Param1} = 'Value1'
${1:Param2} = 'Value2'
${1:Param1} = '{2:Value1}'
${3:Param2} = '{4:Value2}'
}
${3:CommandName}
${5:CommandName} @Params
# PowerShell Enumeration
snippet enum
enum ${0:name} {
${1:item1}
${2:item2}
enum ${1:name} {
${2:item1}
${3:item2}
}
# PowerShell if..then
snippet if
if (${0:condition}) {
${1:statement}
if (${1:condition}) {
${2:statement}
}
# PowerShell if..else
snippet ife
if ( ${1:condition} ) {
${2}
}
else {
${3}
}
# PowerShell While Loop
snippet while
while (${0:condition}) {
${1:statement}
while (${1:condition}) {
${2:statement}
}
# PowerShell Filter..Sort
snippet filtersort
${0:command} | Where-Object -FilterScript { $PSItem.${1:property} -${2:operator} '${3:expression}' } | Sort-Object -Property ${4:sortproperty}
${1:command} | Where-Object -FilterScript { $PSItem.${2:property} -${3:operator} '${4:expression}' } | Sort-Object -Property ${5:sortproperty}
# PowerShell foreach
snippet foreach
foreach ( $${1:iterator} in $${2:collection} ) {
${3:statement}
}
# PowerShell export-csv
snippet epcsv
Export-CSV -NoTypeInformation -Path ${1:path}
# Powershell Comment Based Help
snippet help
<#
.SYNOPSIS
${1:Short Description}
.DESCRIPTION
${2:Full Description}
.PARAMETER ${3:Param1}
${4: $3 usage}
.EXAMPLE
${5:Example}
.NOTES
${6:notes}
.LINK
${7:online help}
#>
# Powershell switch statement
snippet switch
switch ( ${1:test} ){
${2:condition1} { ${3:action} }
${4:condition2} { ${5:action} }
default { ${6:action} }

View File

@ -1,87 +1,60 @@
# Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540
#
# Please contact R.I.Pienaar <rip@devco.net> for additions and feedback,
# Please contact Jorge Vidal <im@jor.ge> for additions and feedback,
# see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php
# Many thanks to the original author R.I.Pienaar <rip@devco.net>
# Header to match http://docs.puppetlabs.com/guides/style_guide.html#puppet-doc
# Header using Puppet Strings (YARD tags) https://puppet.com/docs/puppet/latest/modules_documentation.html
# More info: https://github.com/puppetlabs/puppet-strings
snippet classheader
# == Class: ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:h:h'), 'name')`}
# ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:h:h'), 'class-name')`}
# ${2:A description of what this class does}
#
# ${2:Full description of class $1 here}
# @summary ${3:A short summary of the purpose of this class}
#
# === Parameters
# @param ${4:parameter1} [${5:String}]
# ${6:Explanation of what this parameter affects.}
#
# Document parameters here.
# @example Simple use
# class { '$1': }
#
# [*parameter1*]
# Explanation of what this parameter affects and what it defaults to.
# e.g. "Specify one or more upstream ntp servers as an array."
# @example Use with params
# class { '$1':
# $$4 => '${7:undef}',
# }
#
# === Variables
# @author ${8:`g:snips_author`} <${9:`g:snips_email`}>
#
# Here you should define a list of variables that this module would require.
# @note Copyright `strftime("%Y")` $8
#
# [*variable1*]
# Explanation of how this variable affects the funtion of this class and
# if it has a default. e.g. "The parameter enc_ntp_servers must be set by the
# External Node Classifier as a comma separated list of hostnames."
#
# === Examples
#
# class { '$1':
# parameter1 => [ 'just', 'an', 'example', ]
# }
#
# === Authors
#
# `g:snips_author` <`g:snips_email`>
#
# === Copyright
#
# Copyright `strftime("%Y")` `g:snips_author`
#
class $1 (${3}){
${4}
class $1(
$$4 = undef,
) {
${0}
}
snippet defheader
# == Define: ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:r:s?/manifests/?::?'), 'name')`}
# ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:h:h'), 'define-name')`}
# ${2:A description of what this define does}
#
# ${2:Full description of defined resource type $1 here}
# @summary ${3:A short summary of the purpose of this define}
#
# === Parameters
#
# Document parameters here
#
# [*namevar*]
# If there is a parameter that defaults to the value of the title string
# when not explicitly set, you must always say so. This parameter can be
# referred to as a "namevar," since it's functionally equivalent to the
# namevar of a core resource type.
#
# [*basedir*]
# Description of this variable. For example, "This parameter sets the
# base directory for this resource type. It should not contain a trailing
# slash."
#
# === Examples
#
# Provide some examples on how to use this type:
# @param ${4:parameter1} [${5:String}]
# ${6:Explanation of what this parameter affects.}
#
# @example Simple use
# $1 { 'namevar':
# basedir => '/tmp/src',
# $$4 => '${7:undef}',
# }
#
# === Authors
# @author ${8:`g:snips_author`} <${9:`g:snips_email`}>
#
# `g:snips_author` <`g:snips_email`>
# @note Copyright `strftime("%Y")` $8
#
# === Copyright
#
# Copyright `strftime("%Y")` `g:snips_author`
#
define $1(${3}) {
${4}
define $1(
$$4 = undef,
) {
${0}
}
# Language Constructs

View File

@ -115,21 +115,21 @@ snippet try Try/Except
${1:${VISUAL}}
except ${2:Exception} as ${3:e}:
${0:raise $3}
snippet try Try/Except/Else
snippet trye Try/Except/Else
try:
${1:${VISUAL}}
except ${2:Exception} as ${3:e}:
${4:raise $3}
else:
${0}
snippet try Try/Except/Finally
snippet tryf Try/Except/Finally
try:
${1:${VISUAL}}
except ${2:Exception} as ${3:e}:
${4:raise $3}
finally:
${0}
snippet try Try/Except/Else/Finally
snippet tryef Try/Except/Else/Finally
try:
${1:${VISUAL}}
except ${2:Exception} as ${3:e}:

View File

@ -42,10 +42,10 @@ snippet defcreate
if @$1.save
flash[:notice] = '$2 was successfully created.'
format.html { redirect_to(@$1) }
format.xml { render xml: @$1, status: :created, location: @$1 }
format.json { render json: @$1, status: :created, location: @$1 }
else
format.html { render action: 'new' }
format.xml { render xml: @$1.errors, status: :unprocessable_entity }
format.json { render json: @$1.errors, status: :unprocessable_entity }
end
end
end
@ -56,7 +56,7 @@ snippet defdestroy
respond_to do |format|
format.html { redirect_to($1s_url) }
format.xml { head :ok }
format.json { head :ok }
end
end
snippet defedit
@ -69,7 +69,7 @@ snippet defindex
respond_to do |format|
format.html # index.html.erb
format.xml { render xml: @$1s }
format.json { render json: @$1s }
end
end
snippet defnew
@ -78,7 +78,7 @@ snippet defnew
respond_to do |format|
format.html # new.html.erb
format.xml { render xml: @$1 }
format.json { render json: @$1 }
end
end
snippet defshow
@ -87,7 +87,7 @@ snippet defshow
respond_to do |format|
format.html # show.html.erb
format.xml { render xml: @$1 }
format.json { render json: @$1 }
end
end
snippet defupdate
@ -98,10 +98,10 @@ snippet defupdate
if @$1.update($1_params)
flash[:notice] = '$2 was successfully updated.'
format.html { redirect_to(@$1) }
format.xml { head :ok }
format.json { head :ok }
else
format.html { render action: 'edit' }
format.xml { render xml: @$1.errors, status: :unprocessable_entity }
format.json { render json: @$1.errors, status: :unprocessable_entity }
end
end
end

View File

@ -292,7 +292,9 @@ snippet block block environment
\\begin{block}{${1:title}}
${0:${VISUAL}}
\\end{block}
snippet alert alertblock environment
snippet alert alert text
\\alert{${1:${VISUAL:text}}} ${0}
snippet alertblock alertblock environment
\\begin{alertblock}{${1:title}}
${0:${VISUAL}}
\\end{alertblock}
@ -309,6 +311,12 @@ snippet col2 two-column environment
${0}
\\end{column}
\\end{columns}
snippet multicol2 two-column environment with multicol
\\begin{multicols}{2}
${1}
\columnbreak
${0}
\\end{multicols}
snippet \{ \{ \}
\\{ ${0} \\}
#delimiter