mirror of
https://github.com/amix/vimrc
synced 2025-07-12 22:24:59 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@ -84,6 +84,24 @@ snippet LGPL3
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
${0}
|
||||
snippet AGPL3
|
||||
${1:one line to give the program's name and a brief description.}
|
||||
Copyright (C) `strftime("%Y")` ${2:copyright holder}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
${0}
|
||||
snippet BSD2
|
||||
${1:one line to give the program's name and a brief description}
|
||||
|
@ -965,3 +965,23 @@ snippet z:a
|
||||
z-index: auto;
|
||||
snippet zoo
|
||||
zoom: 1;
|
||||
snippet :h
|
||||
:hover
|
||||
snippet :fc
|
||||
:first-child
|
||||
snippet :lc
|
||||
:last-child
|
||||
snippet :nc
|
||||
:nth-child(${0})
|
||||
snippet :nlc
|
||||
:nth-last-child(${0})
|
||||
snippet :oc
|
||||
:only-child
|
||||
snippet :a
|
||||
:after
|
||||
snippet :b
|
||||
:before
|
||||
snippet ::a
|
||||
::after
|
||||
snippet ::b
|
||||
::before
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
snippet auto
|
||||
${1:FIELDNAME} = models.AutoField(${0})
|
||||
snippet bigint
|
||||
${1:FIELDNAME} = models.BigIntegerField(${0})
|
||||
snippet binary
|
||||
${1:FIELDNAME} = models.BinaryField(${0})
|
||||
snippet bool
|
||||
${1:FIELDNAME} = models.BooleanField(${0:default=True})
|
||||
snippet char
|
||||
@ -80,7 +84,7 @@ snippet model
|
||||
def __unicode__(self):
|
||||
${5}
|
||||
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
def save(self, *args, **kwargs):
|
||||
${6}
|
||||
|
||||
@models.permalink
|
||||
|
@ -6,122 +6,95 @@ snippet if if .. do .. end
|
||||
if ${1} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet if if .. do: ..
|
||||
if ${1:condition}, do: ${0}
|
||||
|
||||
snippet ife if .. do .. else .. end
|
||||
if ${1:condition} do
|
||||
${2}
|
||||
else
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet ife if .. do: .. else:
|
||||
if ${1:condition}, do: ${2}, else: ${0}
|
||||
|
||||
snippet unless unless .. do .. end
|
||||
unless ${1} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet unless unless .. do: ..
|
||||
unless ${1:condition}, do: ${0}
|
||||
|
||||
snippet unlesse unless .. do .. else .. end
|
||||
unless ${1:condition} do
|
||||
${2}
|
||||
else
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet unlesse unless .. do: .. else:
|
||||
unless ${1:condition}, do: ${2}, else: ${0}
|
||||
|
||||
snippet cond
|
||||
cond do
|
||||
${1} ->
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet case
|
||||
case ${1} do
|
||||
${2} ->
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet df
|
||||
def ${1:name}, do: ${2}
|
||||
|
||||
snippet def
|
||||
def ${1:name} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet defim
|
||||
defimpl ${1:protocol_name}, for: ${2:data_type} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet defma
|
||||
defmacro ${1:name} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet defmo
|
||||
defmodule ${1:module_name} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet defp
|
||||
defp ${1:name} do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet defpr
|
||||
defprotocol ${1:name}, [${0:function}]
|
||||
|
||||
snippet defr
|
||||
defrecord ${1:record_name}, ${0:fields}
|
||||
|
||||
snippet doc
|
||||
@doc """
|
||||
${0}
|
||||
"""
|
||||
|
||||
snippet fn
|
||||
fn(${1:args}) -> ${0} end
|
||||
|
||||
snippet fun
|
||||
function do
|
||||
${0}
|
||||
end
|
||||
|
||||
function do
|
||||
${0}
|
||||
end
|
||||
snippet mdoc
|
||||
@moduledoc """
|
||||
${0}
|
||||
"""
|
||||
|
||||
snippet rec
|
||||
receive do
|
||||
${1} ->
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet req
|
||||
require ${0:module_name}
|
||||
|
||||
snippet imp
|
||||
import ${0:module_name}
|
||||
|
||||
snippet ali
|
||||
alias ${0:module_name}
|
||||
|
||||
snippet test
|
||||
test "${1:test_name}" do
|
||||
${0}
|
||||
end
|
||||
|
||||
snippet try try .. rescue .. end
|
||||
try do
|
||||
${1}
|
||||
|
@ -120,8 +120,12 @@ snippet gen_server
|
||||
]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
-export([init/1,
|
||||
handle_call/3,
|
||||
handle_cast/2,
|
||||
handle_info/2,
|
||||
terminate/2,
|
||||
code_change/3]).
|
||||
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
@ -157,6 +161,320 @@ snippet gen_server
|
||||
code_change(_OldVsn, State, _Extra) ->
|
||||
{ok, State}.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
# OTP gen_fsm
|
||||
snippet gen_fsm
|
||||
-module(${0:`vim_snippets#Filename('', 'my')`}).
|
||||
|
||||
-behaviour(gen_fsm).
|
||||
|
||||
%% API
|
||||
-export([start_link/0]).
|
||||
|
||||
%% gen_fsm callbacks
|
||||
-export([init/1,
|
||||
state_name/2,
|
||||
state_name/3,
|
||||
handle_event/3,
|
||||
handle_sync_event/4,
|
||||
handle_info/3,
|
||||
terminate/3,
|
||||
code_change/4]).
|
||||
|
||||
-record(state, {}).
|
||||
|
||||
%%%===================================================================
|
||||
%%% API
|
||||
%%%===================================================================
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% Creates a gen_fsm process which calls Module:init/1 to
|
||||
%% initialize. To ensure a synchronized start-up procedure, this
|
||||
%% function does not return until Module:init/1 has returned.
|
||||
%%
|
||||
%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
start_link() ->
|
||||
gen_fsm:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_fsm callbacks
|
||||
%%%===================================================================
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever a gen_fsm is started using gen_fsm:start/[3,4] or
|
||||
%% gen_fsm:start_link/[3,4], this function is called by the new
|
||||
%% process to initialize.
|
||||
%%
|
||||
%% @spec init(Args) -> {ok, StateName, State} |
|
||||
%% {ok, StateName, State, Timeout} |
|
||||
%% ignore |
|
||||
%% {stop, StopReason}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
init([]) ->
|
||||
{ok, state_name, #state{}}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% There should be one instance of this function for each possible
|
||||
%% state name. Whenever a gen_fsm receives an event sent using
|
||||
%% gen_fsm:send_event/2, the instance of this function with the same
|
||||
%% name as the current state name StateName is called to handle
|
||||
%% the event. It is also called if a timeout occurs.
|
||||
%%
|
||||
%% @spec state_name(Event, State) ->
|
||||
%% {next_state, NextStateName, NextState} |
|
||||
%% {next_state, NextStateName, NextState, Timeout} |
|
||||
%% {stop, Reason, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
state_name(_Event, State) ->
|
||||
{next_state, state_name, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% There should be one instance of this function for each possible
|
||||
%% state name. Whenever a gen_fsm receives an event sent using
|
||||
%% gen_fsm:sync_send_event/[2,3], the instance of this function with
|
||||
%% the same name as the current state name StateName is called to
|
||||
%% handle the event.
|
||||
%%
|
||||
%% @spec state_name(Event, From, State) ->
|
||||
%% {next_state, NextStateName, NextState} |
|
||||
%% {next_state, NextStateName, NextState, Timeout} |
|
||||
%% {reply, Reply, NextStateName, NextState} |
|
||||
%% {reply, Reply, NextStateName, NextState, Timeout} |
|
||||
%% {stop, Reason, NewState} |
|
||||
%% {stop, Reason, Reply, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
state_name(_Event, _From, State) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, state_name, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever a gen_fsm receives an event sent using
|
||||
%% gen_fsm:send_all_state_event/2, this function is called to handle
|
||||
%% the event.
|
||||
%%
|
||||
%% @spec handle_event(Event, StateName, State) ->
|
||||
%% {next_state, NextStateName, NextState} |
|
||||
%% {next_state, NextStateName, NextState, Timeout} |
|
||||
%% {stop, Reason, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
handle_event(_Event, StateName, State) ->
|
||||
{next_state, StateName, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever a gen_fsm receives an event sent using
|
||||
%% gen_fsm:sync_send_all_state_event/[2,3], this function is called
|
||||
%% to handle the event.
|
||||
%%
|
||||
%% @spec handle_sync_event(Event, From, StateName, State) ->
|
||||
%% {next_state, NextStateName, NextState} |
|
||||
%% {next_state, NextStateName, NextState, Timeout} |
|
||||
%% {reply, Reply, NextStateName, NextState} |
|
||||
%% {reply, Reply, NextStateName, NextState, Timeout} |
|
||||
%% {stop, Reason, NewState} |
|
||||
%% {stop, Reason, Reply, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
handle_sync_event(_Event, _From, StateName, State) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% This function is called by a gen_fsm when it receives any
|
||||
%% message other than a synchronous or asynchronous event
|
||||
%% (or a system message).
|
||||
%%
|
||||
%% @spec handle_info(Info,StateName,State)->
|
||||
%% {next_state, NextStateName, NextState} |
|
||||
%% {next_state, NextStateName, NextState, Timeout} |
|
||||
%% {stop, Reason, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
handle_info(_Info, StateName, State) ->
|
||||
{next_state, StateName, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% This function is called by a gen_fsm when it is about to
|
||||
%% terminate. It should be the opposite of Module:init/1 and do any
|
||||
%% necessary cleaning up. When it returns, the gen_fsm terminates with
|
||||
%% Reason. The return value is ignored.
|
||||
%%
|
||||
%% @spec terminate(Reason, StateName, State) -> void()
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
terminate(_Reason, _StateName, _State) ->
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Convert process state when code is changed
|
||||
%%
|
||||
%% @spec code_change(OldVsn, StateName, State, Extra) ->
|
||||
%% {ok, StateName, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
code_change(_OldVsn, StateName, State, _Extra) ->
|
||||
{ok, StateName, State}.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
# OTP gen_event
|
||||
snippet gen_event
|
||||
-module(${0:`vim_snippets#Filename('', 'my')`}).
|
||||
|
||||
-behaviour(gen_event).
|
||||
|
||||
%% API
|
||||
-export([start_link/0,
|
||||
add_handler/2]).
|
||||
|
||||
%% gen_event callbacks
|
||||
-export([init/1,
|
||||
handle_event/2,
|
||||
handle_call/2,
|
||||
handle_info/2,
|
||||
terminate/2,
|
||||
code_change/3]).
|
||||
|
||||
-record(state, {}).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_event callbacks
|
||||
%%%===================================================================
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% Creates an event manager
|
||||
%%
|
||||
%% @spec start_link() -> {ok, Pid} | {error, Error}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
start_link() ->
|
||||
gen_event:start_link({local, ?MODULE}).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% Adds an event handler
|
||||
%%
|
||||
%% @spec add_handler(Handler, Args) -> ok | {'EXIT', Reason} | term()
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
add_handler(Handler, Args) ->
|
||||
gen_event:add_handler(?MODULE, Handler, Args).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_event callbacks
|
||||
%%%===================================================================
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever a new event handler is added to an event manager,
|
||||
%% this function is called to initialize the event handler.
|
||||
%%
|
||||
%% @spec init(Args) -> {ok, State}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
init([]) ->
|
||||
{ok, #state{}}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever an event manager receives an event sent using
|
||||
%% gen_event:notify/2 or gen_event:sync_notify/2, this function is
|
||||
%% called for each installed event handler to handle the event.
|
||||
%%
|
||||
%% @spec handle_event(Event, State) ->
|
||||
%% {ok, State} |
|
||||
%% {swap_handler, Args1, State1, Mod2, Args2} |
|
||||
%% remove_handler
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
handle_event(_Event, State) ->
|
||||
{ok, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever an event manager receives a request sent using
|
||||
%% gen_event:call/3,4, this function is called for the specified
|
||||
%% event handler to handle the request.
|
||||
%%
|
||||
%% @spec handle_call(Request, State) ->
|
||||
%% {ok, Reply, State} |
|
||||
%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |
|
||||
%% {remove_handler, Reply}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
handle_call(_Request, State) ->
|
||||
Reply = ok,
|
||||
{ok, Reply, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% This function is called for each installed event handler when
|
||||
%% an event manager receives any other message than an event or a
|
||||
%% synchronous request (or a system message).
|
||||
%%
|
||||
%% @spec handle_info(Info, State) ->
|
||||
%% {ok, State} |
|
||||
%% {swap_handler, Args1, State1, Mod2, Args2} |
|
||||
%% remove_handler
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
handle_info(_Info, State) ->
|
||||
{ok, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Whenever an event handler is deleted from an event manager, this
|
||||
%% function is called. It should be the opposite of Module:init/1 and
|
||||
%% do any necessary cleaning up.
|
||||
%%
|
||||
%% @spec terminate(Reason, State) -> void()
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
terminate(_Reason, _State) ->
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Convert process state when code is changed
|
||||
%%
|
||||
%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
code_change(_OldVsn, State, _Extra) ->
|
||||
{ok, State}.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
|
@ -107,6 +107,8 @@ snippet ntc
|
||||
<%= number_to_currency(${1}) %>
|
||||
snippet ofcfs
|
||||
<%= options_from_collection_for_select ${1:collection}, ${2:value_method}, ${3:text_method}, ${0:selected_value} %>
|
||||
snippet ofs
|
||||
<%= options_for_select ${1:collection}, ${2:value_method} %>
|
||||
snippet rf
|
||||
<%= render :file => "${1:file}"${0} %>
|
||||
snippet rt
|
||||
|
@ -230,3 +230,15 @@ snippet ga
|
||||
go func(${1} ${2:type}) {
|
||||
${3:/* code */}
|
||||
}(${0})
|
||||
snippet test test function
|
||||
func Test${1:name}(t *testing.T) {
|
||||
${2}
|
||||
}
|
||||
${0}
|
||||
snippet bench benchmark function
|
||||
func Benchmark${1:name}(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
${2}
|
||||
}
|
||||
}
|
||||
${0}
|
||||
|
@ -1,5 +1,7 @@
|
||||
snippet lang
|
||||
{-# LANGUAGE ${0:OverloadedStrings} #-}
|
||||
snippet haddock
|
||||
{-# OPTIONS_HADDOCK ${0:hide} #-}
|
||||
snippet info
|
||||
-- |
|
||||
-- Module : ${1:Module.Namespace}
|
||||
|
@ -47,6 +47,9 @@ snippet backspace
|
||||
# ⎋
|
||||
snippet esc
|
||||
⎋
|
||||
# comment
|
||||
snippet //
|
||||
<!-- ${1} -->${0}
|
||||
# Generic Doctype
|
||||
snippet doctype HTML 4.01 Strict
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
@ -147,6 +150,8 @@ snippet a:ext
|
||||
<a href="http://${1:example.com}">${0:$1}</a>
|
||||
snippet a:mail
|
||||
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${0:email me}</a>
|
||||
snippet ac
|
||||
<a href="`@+`">${0:`@+`}</a>
|
||||
snippet abbr
|
||||
<abbr title="${1}">${0}</abbr>
|
||||
snippet address
|
||||
@ -325,7 +330,7 @@ snippet dt+
|
||||
snippet em
|
||||
<em>${0}</em>
|
||||
snippet embed
|
||||
<embed src=${1} type="${0} />
|
||||
<embed src="${1}" type="${0}" />
|
||||
snippet fieldset
|
||||
<fieldset>
|
||||
${0}
|
||||
@ -348,6 +353,14 @@ snippet figcaption
|
||||
<figcaption>${0}</figcaption>
|
||||
snippet figure
|
||||
<figure>${0}</figure>
|
||||
snippet figure#
|
||||
<figure id="${1}">
|
||||
${0}
|
||||
</figure>
|
||||
snippet figure.
|
||||
<figure class="${1}">
|
||||
${0}
|
||||
</figure>
|
||||
snippet footer
|
||||
<footer>
|
||||
${0}
|
||||
@ -449,9 +462,23 @@ snippet html5
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||
${2:meta}
|
||||
${2:link}
|
||||
</head>
|
||||
<body>
|
||||
${0:body}
|
||||
</body>
|
||||
</html>
|
||||
snippet html5l
|
||||
<!DOCTYPE html>
|
||||
<html lang="${1:es}">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>${2:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||
${3:link}
|
||||
</head>
|
||||
<body>
|
||||
${0:body}
|
||||
@ -555,6 +582,8 @@ snippet link
|
||||
<link rel="${1}" href="${2}" title="${3}" type="${4}" />
|
||||
snippet link:atom
|
||||
<link rel="alternate" href="${1:atom.xml}" title="Atom" type="application/atom+xml" />
|
||||
snippet link:s
|
||||
<link rel="stylesheet" href="${1:style.css}" />
|
||||
snippet link:css
|
||||
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />
|
||||
snippet link:favicon
|
||||
@ -595,6 +624,10 @@ snippet menu:t
|
||||
</menu>
|
||||
snippet meta
|
||||
<meta http-equiv="${1}" content="${2}" />
|
||||
snippet meta:s
|
||||
<meta ${0} />
|
||||
snippet meta:d
|
||||
<meta name="description" content="${0}" />
|
||||
snippet meta:compat
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=${1:7,8,edge}" />
|
||||
snippet meta:refresh
|
||||
@ -626,7 +659,7 @@ snippet object
|
||||
# Embed QT Movie
|
||||
snippet movie
|
||||
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
|
||||
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||
<param name="src" value="$1" />
|
||||
<param name="controller" value="$4" />
|
||||
<param name="autoplay" value="$5" />
|
||||
@ -697,6 +730,12 @@ snippet script
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
${0}
|
||||
</script>
|
||||
snippet scripts
|
||||
<script src="${0}.js"></script>
|
||||
snippet scriptt
|
||||
<script type="${1}" id="${2}">
|
||||
${0}
|
||||
</script>
|
||||
snippet scriptsrc
|
||||
<script src="${0}.js" type="text/javascript" charset="utf-8"></script>
|
||||
snippet section
|
||||
@ -774,7 +813,7 @@ snippet td+
|
||||
<td>${1}</td>
|
||||
td+${0}
|
||||
snippet textarea
|
||||
<textarea name="${1}" id=${2:$1} rows="${3:8}" cols="${4:40}">${5}</textarea>
|
||||
<textarea name="${1}" id="${2:$1}" rows="${3:8}" cols="${4:40}">${5}</textarea>
|
||||
snippet tfoot
|
||||
<tfoot>
|
||||
${0}
|
||||
|
@ -1,10 +1,10 @@
|
||||
## Access Modifiers
|
||||
snippet po
|
||||
protected
|
||||
protected ${0}
|
||||
snippet pu
|
||||
public
|
||||
public ${0}
|
||||
snippet pr
|
||||
private
|
||||
private ${0}
|
||||
##
|
||||
## Annotations
|
||||
snippet before
|
||||
@ -25,7 +25,7 @@ snippet oo
|
||||
##
|
||||
## Basic Java packages and import
|
||||
snippet im
|
||||
import
|
||||
import ${0}
|
||||
snippet j.b
|
||||
java.beans.
|
||||
snippet j.i
|
||||
@ -39,17 +39,19 @@ snippet j.u
|
||||
##
|
||||
## Class
|
||||
snippet cl
|
||||
class ${1:`vim_snippets#Filename("", "untitled")`} ${0}
|
||||
class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
|
||||
snippet pcl
|
||||
public class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
|
||||
snippet in
|
||||
interface ${1:`vim_snippets#Filename("", "untitled")`} ${2:extends Parent}
|
||||
interface ${1:`vim_snippets#Filename("$1", "untitled")`} ${2:extends Parent}
|
||||
snippet tc
|
||||
public class ${1:`vim_snippets#Filename()`} extends ${0:TestCase}
|
||||
public class ${1:`vim_snippets#Filename("$1")`} extends ${0:TestCase}
|
||||
##
|
||||
## Class Enhancements
|
||||
snippet ext
|
||||
extends
|
||||
extends ${0}
|
||||
snippet imp
|
||||
implements
|
||||
implements ${0}
|
||||
##
|
||||
## Comments
|
||||
snippet /*
|
||||
@ -89,15 +91,40 @@ snippet m
|
||||
snippet v
|
||||
${1:String} ${2:var}${3: = null}${4};
|
||||
##
|
||||
## Declaration for ArrayList
|
||||
snippet d.al
|
||||
List<${1:Object}> ${2:list} = new ArrayList<$1>();${0}
|
||||
## Declaration for HashMap
|
||||
snippet d.hm
|
||||
Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0}
|
||||
## Declaration for HashSet
|
||||
snippet d.hs
|
||||
Set<${1:Object}> ${2:set} = new HashSet<$1>();${0}
|
||||
## Declaration for Stack
|
||||
snippet d.st
|
||||
Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0}
|
||||
##
|
||||
## Singleton Pattern
|
||||
snippet singlet
|
||||
private static class Holder {
|
||||
private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1();
|
||||
}
|
||||
|
||||
private $1() { }
|
||||
|
||||
public static $1 getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
##
|
||||
## Enhancements to Methods, variables, classes, etc.
|
||||
snippet ab
|
||||
abstract
|
||||
abstract ${0}
|
||||
snippet fi
|
||||
final
|
||||
final ${0}
|
||||
snippet st
|
||||
static
|
||||
static ${0}
|
||||
snippet sy
|
||||
synchronized
|
||||
synchronized ${0}
|
||||
##
|
||||
## Error Methods
|
||||
snippet err
|
||||
@ -110,12 +137,30 @@ snippet errln
|
||||
## Exception Handling
|
||||
snippet as
|
||||
assert ${1:test} : "${2:Failure message}";
|
||||
snippet ae
|
||||
assertEquals("${1:Failure message}", ${2:expected}, ${3:actual});
|
||||
snippet aae
|
||||
assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals});
|
||||
snippet af
|
||||
assertFalse("${1:Failure message}", ${2:condition});
|
||||
snippet at
|
||||
assertTrue("${1:Failure message}", ${2:condition});
|
||||
snippet an
|
||||
assertNull("${1:Failure message}", ${2:object});
|
||||
snippet ann
|
||||
assertNotNull("${1:Failure message}", ${2:object});
|
||||
snippet ass
|
||||
assertSame("${1:Failure message}", ${2:expected}, ${3:actual});
|
||||
snippet asns
|
||||
assertNotSame("${1:Failure message}", ${2:expected}, ${3:actual});
|
||||
snippet fa
|
||||
fail("${1:Failure message}");
|
||||
snippet ca
|
||||
catch(${1:Exception} ${2:e}) ${0}
|
||||
snippet thr
|
||||
throw
|
||||
throw ${0}
|
||||
snippet ths
|
||||
throws
|
||||
throws ${0}
|
||||
snippet try
|
||||
try {
|
||||
${0}
|
||||
@ -144,7 +189,7 @@ snippet @au
|
||||
snippet @br
|
||||
@brief ${0:Description}
|
||||
snippet @fi
|
||||
@file ${0:`vim_snippets#Filename()`}.java
|
||||
@file ${0:`vim_snippets#Filename("$1")`}.java
|
||||
snippet @pa
|
||||
@param ${0:param}
|
||||
snippet @re
|
||||
@ -206,7 +251,7 @@ snippet get
|
||||
##
|
||||
## Terminate Methods or Loops
|
||||
snippet re
|
||||
return
|
||||
return ${0}
|
||||
snippet br
|
||||
break;
|
||||
##
|
||||
|
@ -1,22 +1,26 @@
|
||||
# Prototype
|
||||
# prototype
|
||||
snippet proto
|
||||
${1:class_name}.prototype.${2:method_name} =
|
||||
function(${3:first_argument}) {
|
||||
${0:// body...}
|
||||
${1:class_name}.prototype.${2:method_name} = function(${3}) {
|
||||
${0}
|
||||
};
|
||||
# Function
|
||||
snippet fun
|
||||
function ${1:function_name}(${2:argument}) {
|
||||
${0:// body...}
|
||||
function ${1:function_name}(${2}) {
|
||||
${0}
|
||||
}
|
||||
# Anonymous Function
|
||||
snippet f
|
||||
function (${1}) {
|
||||
function(${1}) {
|
||||
${0}
|
||||
}${2:;}
|
||||
}
|
||||
# Function assigned to variable
|
||||
snippet vf
|
||||
var ${1:function_name} = function $1(${2}) {
|
||||
${0}
|
||||
};
|
||||
# Immediate function
|
||||
snippet (f
|
||||
(function (${1}) {
|
||||
(function(${1}) {
|
||||
${0}
|
||||
}(${2}));
|
||||
# if
|
||||
@ -94,6 +98,9 @@ snippet gett
|
||||
# console.log (Firebug)
|
||||
snippet cl
|
||||
console.log(${0});
|
||||
# console.debug (Firebug)
|
||||
snippet cd
|
||||
console.debug(${0});
|
||||
# return
|
||||
snippet ret
|
||||
return ${0:result}
|
||||
|
@ -349,3 +349,11 @@ snippet debug_trace
|
||||
require Carp; Carp::confess
|
||||
};
|
||||
|
||||
snippet dump
|
||||
use Data::Dump qw(dump);
|
||||
warn dump ${1:variable}
|
||||
|
||||
snippet subtest
|
||||
subtest '${1: test_name}' => sub {
|
||||
${2}
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ snippet i
|
||||
snippet t.
|
||||
$this->
|
||||
snippet f
|
||||
function ${1:foo}(${2:array }${3:$bar})
|
||||
function ${1}(${3})
|
||||
{
|
||||
${0}
|
||||
}
|
||||
@ -347,6 +347,10 @@ snippet vd
|
||||
var_dump(${0});
|
||||
snippet vdd
|
||||
var_dump(${1}); die(${0:});
|
||||
snippet pr
|
||||
print_r(${0});
|
||||
snippet prs
|
||||
print_r(${0}, 1);
|
||||
snippet vdf
|
||||
error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');
|
||||
snippet http_redirect
|
||||
|
@ -1,5 +1,6 @@
|
||||
snippet #!
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
snippet imp
|
||||
import ${0:module}
|
||||
snippet uni
|
||||
@ -200,3 +201,10 @@ snippet epydoc
|
||||
|
||||
@raise e: ${0: Description}
|
||||
"""
|
||||
snippet dol
|
||||
def ${1:__init__}(self, *args, **kwargs):
|
||||
super(${0:ClassName}, self).$1(*args, **kwargs)
|
||||
snippet kwg
|
||||
self.${1:var_name} = kwargs.get('$1', ${2:None})
|
||||
snippet lkwg
|
||||
${1:var_name} = kwargs.get('$1', ${2:None})
|
||||
|
@ -23,9 +23,19 @@ snippet ei
|
||||
${0}
|
||||
}
|
||||
|
||||
# loops
|
||||
snippet wh
|
||||
while(${1}) {
|
||||
${2}
|
||||
}
|
||||
snippet for
|
||||
for (${1:item} in ${2:list}) {
|
||||
${3}
|
||||
}
|
||||
|
||||
# functions
|
||||
snippet fun
|
||||
${1:name} = function (${2:variables}) {
|
||||
${1:name} <- function (${2:variables}) {
|
||||
${0}
|
||||
}
|
||||
snippet ret
|
||||
@ -39,7 +49,7 @@ snippet c
|
||||
snippet li
|
||||
list(${0:items})
|
||||
snippet mat
|
||||
matrix(${1:data}, nrow=${2:rows}, ncol=${0:cols})
|
||||
matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
|
||||
|
||||
# apply functions
|
||||
snippet apply
|
||||
@ -100,7 +110,7 @@ snippet pl
|
||||
snippet ggp
|
||||
ggplot(${1:data}, aes(${0:aesthetics}))
|
||||
snippet img
|
||||
${1:(jpeg,bmp,png,tiff)}(filename="${2:filename}", width=${3}, height=${4}, unit="${5}")
|
||||
${1:(jpeg,bmp,png,tiff)}(filename = '${2:filename}', width = ${3}, height = ${4}, unit = '${5}')
|
||||
${0:plot}
|
||||
dev.off()
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
########################################
|
||||
# Ruby snippets - for Rails, see below #
|
||||
########################################
|
||||
|
||||
# encoding for Ruby 1.9
|
||||
snippet enc
|
||||
# encoding: utf-8
|
||||
@ -35,9 +31,9 @@ snippet beg
|
||||
end
|
||||
|
||||
snippet req require
|
||||
require "${1}"
|
||||
require '${1}'
|
||||
snippet reqr
|
||||
require_relative "${1}"
|
||||
require_relative '${1}'
|
||||
snippet #
|
||||
# =>
|
||||
snippet end
|
||||
@ -61,7 +57,7 @@ snippet deft
|
||||
snippet descendants
|
||||
class Class
|
||||
def descendants
|
||||
ObjectSpace.each_object(::Class).select {|klass| klass < self }
|
||||
ObjectSpace.each_object(::Class).select { |klass| klass < self }
|
||||
end
|
||||
end
|
||||
snippet if
|
||||
@ -232,13 +228,13 @@ snippet array
|
||||
snippet hash
|
||||
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${0} }
|
||||
snippet file File.foreach() { |line| .. }
|
||||
File.foreach(${1:"path/to/file"}) { |${2:line}| ${0} }
|
||||
File.foreach(${1:'path/to/file'}) { |${2:line}| ${0} }
|
||||
snippet file File.read()
|
||||
File.read(${1:"path/to/file"})
|
||||
File.read(${1:'path/to/file'})
|
||||
snippet Dir Dir.global() { |file| .. }
|
||||
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${0} }
|
||||
Dir.glob(${1:'dir/glob/*'}) { |${2:file}| ${0} }
|
||||
snippet Dir Dir[".."]
|
||||
Dir[${1:"glob/**/*.rb"}]
|
||||
Dir[${1:'glob/**/*.rb'}]
|
||||
snippet dir
|
||||
Filename.dirname(__FILE__)
|
||||
snippet deli
|
||||
@ -247,7 +243,7 @@ snippet fil
|
||||
fill(${1:range}) { |${2:i}| ${0} }
|
||||
# flatten_once()
|
||||
snippet flao
|
||||
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}
|
||||
reduce(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2) }
|
||||
snippet zip
|
||||
zip(${1:enums}) { |${2:row}| ${0} }
|
||||
# downto(0) { |n| .. }
|
||||
@ -419,6 +415,10 @@ snippet seld
|
||||
end
|
||||
snippet lam
|
||||
lambda { |${1:args}| ${0} }
|
||||
snippet ->
|
||||
-> { ${0} }
|
||||
snippet ->a
|
||||
->(${1:args}) { ${0} }
|
||||
# I'm pretty sure that ruby users expect do to expand to do .. end
|
||||
snippet do
|
||||
do
|
||||
@ -432,12 +432,12 @@ snippet dov
|
||||
${2}
|
||||
end
|
||||
snippet :
|
||||
:${1:key} => ${2:"value"}
|
||||
${1:key}: ${2:'value'}
|
||||
snippet ope
|
||||
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${0} }
|
||||
open('${1:path/or/url/or/pipe}', '${2:w}') { |${3:io}| ${0} }
|
||||
# path_from_here()
|
||||
snippet fpath
|
||||
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])
|
||||
File.join(File.dirname(__FILE__), *['${1:rel path here}'])
|
||||
# unix_filter {}
|
||||
snippet unif
|
||||
ARGF.each_line${1} do |${2:line}|
|
||||
@ -445,21 +445,21 @@ snippet unif
|
||||
end
|
||||
# option_parse {}
|
||||
snippet optp
|
||||
require "optparse"
|
||||
require 'optparse'
|
||||
|
||||
options = {${0:default => "args"}}
|
||||
options = { ${0:default: 'args'} }
|
||||
|
||||
ARGV.options do |opts|
|
||||
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
|
||||
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}"
|
||||
end
|
||||
snippet opt
|
||||
opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
|
||||
"${4:Option description.}") do |${5:opt}|
|
||||
opts.on('-${1:o}', '--${2:long-option-name}', ${3:String}, '${4:Option description.}') do |${5:opt}|
|
||||
${0}
|
||||
end
|
||||
snippet tc
|
||||
require "test/unit"
|
||||
require 'test/unit'
|
||||
|
||||
require "${1:library_file_name}"
|
||||
require '${1:library_file_name}'
|
||||
|
||||
class Test${2:$1} < Test::Unit::TestCase
|
||||
def test_${3:case_name}
|
||||
@ -467,18 +467,20 @@ snippet tc
|
||||
end
|
||||
end
|
||||
snippet ts
|
||||
require "test/unit"
|
||||
require 'test/unit'
|
||||
|
||||
require "tc_${1:test_case_file}"
|
||||
require "tc_${2:test_case_file}"
|
||||
require 'tc_${1:test_case_file}'
|
||||
require 'tc_${2:test_case_file}'
|
||||
snippet as
|
||||
assert ${1:test}, "${2:Failure message.}"
|
||||
assert ${1:test}, '${2:Failure message.}'
|
||||
snippet ase
|
||||
assert_equal ${1:expected}, ${2:actual}
|
||||
snippet asne
|
||||
assert_not_equal ${1:unexpected}, ${2:actual}
|
||||
snippet asid
|
||||
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2 ** -20}
|
||||
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2**-20}
|
||||
snippet asi
|
||||
assert_includes ${1:collection}, ${2:object}
|
||||
snippet asio
|
||||
assert_instance_of ${1:ExpectedClass}, ${2:actual_instance}
|
||||
snippet asko
|
||||
@ -488,9 +490,9 @@ snippet asn
|
||||
snippet asnn
|
||||
assert_not_nil ${1:instance}
|
||||
snippet asm
|
||||
assert_match /${1:expected_pattern}/, ${2:actual_string}
|
||||
assert_match(/${1:expected_pattern}/, ${2:actual_string})
|
||||
snippet asnm
|
||||
assert_no_match /${1:unexpected_pattern}/, ${2:actual_string}
|
||||
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})
|
||||
snippet aso
|
||||
assert_operator ${1:left}, :${2:operator}, ${3:right}
|
||||
snippet asr
|
||||
@ -514,7 +516,7 @@ snippet ass assert_send(..)
|
||||
snippet asns
|
||||
assert_not_same ${1:unexpected}, ${2:actual}
|
||||
snippet ast
|
||||
assert_throws :${1:expected} { ${0} }
|
||||
assert_throws :${1:expected}, -> { ${0} }
|
||||
snippet astd
|
||||
assert_throws :${1:expected} do
|
||||
${0}
|
||||
@ -526,7 +528,7 @@ snippet asntd
|
||||
${0}
|
||||
end
|
||||
snippet fl
|
||||
flunk "${1:Failure message.}"
|
||||
flunk '${1:Failure message.}'
|
||||
# Benchmark.bmbm do .. end
|
||||
snippet bm-
|
||||
TESTS = ${1:10_000}
|
||||
@ -534,31 +536,31 @@ snippet bm-
|
||||
${0}
|
||||
end
|
||||
snippet rep
|
||||
results.report("${1:name}:") { TESTS.times { ${0} }}
|
||||
results.report('${1:name}:') { TESTS.times { ${0} } }
|
||||
# Marshal.dump(.., file)
|
||||
snippet Md
|
||||
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }
|
||||
File.open('${1:path/to/file.dump}', 'wb') { |${2:file}| Marshal.dump(${3:obj}, $2) }
|
||||
# Mashal.load(obj)
|
||||
snippet Ml
|
||||
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }
|
||||
File.open('${1:path/to/file.dump}', 'rb') { |${2:file}| Marshal.load($2) }
|
||||
# deep_copy(..)
|
||||
snippet deec
|
||||
Marshal.load(Marshal.dump(${1:obj_to_copy}))
|
||||
snippet Pn-
|
||||
PStore.new(${1:"file_name.pstore"})
|
||||
PStore.new('${1:file_name.pstore}')
|
||||
snippet tra
|
||||
transaction(${1:true}) { ${0} }
|
||||
# xmlread(..)
|
||||
snippet xml-
|
||||
REXML::Document.new(File.read(${1:"path/to/file"}))
|
||||
REXML::Document.new(File.read('${1:path/to/file}'))
|
||||
# xpath(..) { .. }
|
||||
snippet xpa
|
||||
elements.each(${1:"//Xpath"}) do |${2:node}|
|
||||
elements.each('${1://Xpath}') do |${2:node}|
|
||||
${0}
|
||||
end
|
||||
# class_from_name()
|
||||
snippet clafn
|
||||
split("::").inject(Object) { |par, const| par.const_get(const) }
|
||||
split('::').inject(Object) { |par, const| par.const_get(const) }
|
||||
# singleton_class()
|
||||
snippet sinc
|
||||
class << self; self end
|
||||
@ -567,8 +569,8 @@ snippet nam
|
||||
${0}
|
||||
end
|
||||
snippet tas
|
||||
desc "${1:Task description}"
|
||||
task :${2:task_name => [:dependent, :tasks]} do
|
||||
desc '${1:Task description}'
|
||||
task ${2:task_name: [:dependent, :tasks]} do
|
||||
${0}
|
||||
end
|
||||
# block
|
||||
@ -576,7 +578,7 @@ snippet b
|
||||
{ |${1:var}| ${0} }
|
||||
snippet begin
|
||||
begin
|
||||
raise 'A test exception.'
|
||||
fail 'A test exception.'
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
puts e.backtrace.inspect
|
||||
@ -588,381 +590,76 @@ snippet begin
|
||||
|
||||
#debugging
|
||||
snippet debug
|
||||
require 'ruby-debug'; debugger; true;
|
||||
require 'byebug'; byebug
|
||||
snippet debug19
|
||||
require 'debugger'; debugger
|
||||
snippet debug18
|
||||
require 'ruby-debug'; debugger
|
||||
snippet pry
|
||||
require 'pry'; binding.pry
|
||||
snippet strf
|
||||
strftime("${1:%Y-%m-%d %H:%M:%S %z}")${0}
|
||||
#############################################
|
||||
# Rails snippets - for pure Ruby, see above #
|
||||
#############################################
|
||||
snippet art
|
||||
assert_redirected_to ${1::action => "${2:index}"}
|
||||
snippet artnp
|
||||
assert_redirected_to ${1:parent}_${2:child}_path(${3:@$1}, ${0:@$2})
|
||||
snippet artnpp
|
||||
assert_redirected_to ${1:parent}_${2:child}_path(${0:@$1})
|
||||
snippet artp
|
||||
assert_redirected_to ${1:model}_path(${0:@$1})
|
||||
snippet artpp
|
||||
assert_redirected_to ${0:model}s_path
|
||||
snippet asd
|
||||
assert_difference "${1:Model}.${2:count}", ${3:1} do
|
||||
${0}
|
||||
end
|
||||
snippet asnd
|
||||
assert_no_difference "${1:Model}.${2:count}" do
|
||||
${0}
|
||||
end
|
||||
snippet asre
|
||||
assert_response :${1:success}, @response.body
|
||||
snippet asrj
|
||||
assert_rjs :${1:replace}, "${0:dom id}"
|
||||
snippet ass assert_select(..)
|
||||
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
|
||||
snippet ba
|
||||
before_action :${0:method}
|
||||
snippet bf
|
||||
before_filter :${0:method}
|
||||
snippet bt
|
||||
belongs_to :${0:association}
|
||||
snippet btp
|
||||
belongs_to :${1:association}, :polymorphic => true
|
||||
snippet crw
|
||||
cattr_accessor :${0:attr_names}
|
||||
snippet defcreate
|
||||
def create
|
||||
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
|
||||
|
||||
respond_to do |format|
|
||||
if @$1.save
|
||||
flash[:notice] = '$2 was successfully created.'
|
||||
format.html { redirect_to(@$1) }
|
||||
format.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
snippet defdestroy
|
||||
def destroy
|
||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||
@$1.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to($1s_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
snippet defedit
|
||||
def edit
|
||||
@${1:model_class_name} = ${0:ModelClassName}.find(params[:id])
|
||||
end
|
||||
snippet defindex
|
||||
def index
|
||||
@${1:model_class_name} = ${2:ModelClassName}.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @$1s }
|
||||
end
|
||||
end
|
||||
snippet defnew
|
||||
def new
|
||||
@${1:model_class_name} = ${2:ModelClassName}.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @$1 }
|
||||
end
|
||||
end
|
||||
snippet defshow
|
||||
def show
|
||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @$1 }
|
||||
end
|
||||
end
|
||||
snippet defupdate
|
||||
def update
|
||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @$1.update_attributes(params[:$1])
|
||||
flash[:notice] = '$2 was successfully updated.'
|
||||
format.html { redirect_to(@$1) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
snippet dele delegate .. to
|
||||
delegate :${1:methods}, :to => :${0:object}
|
||||
snippet dele delegate .. to .. prefix .. allow_nil
|
||||
delegate :${1:methods}, :to => :${2:object}, :prefix => :${3:prefix}, :allow_nil => ${0:allow_nil}
|
||||
snippet flash
|
||||
flash[:${1:notice}] = "${0}"
|
||||
snippet habtm
|
||||
has_and_belongs_to_many :${1:object}, :join_table => "${2:table_name}", :foreign_key => "${3}_id"
|
||||
snippet hm
|
||||
has_many :${0:object}
|
||||
snippet hmd
|
||||
has_many :${1:other}s, :class_name => "${2:$1}", :foreign_key => "${3:$1}_id", :dependent => :destroy
|
||||
snippet hmt
|
||||
has_many :${1:object}, :through => :${0:object}
|
||||
snippet ho
|
||||
has_one :${0:object}
|
||||
snippet hod
|
||||
has_one :${1:object}, dependent: :${0:destroy}
|
||||
snippet i18
|
||||
I18n.t('${1:type.key}')
|
||||
snippet ist
|
||||
<%= image_submit_tag("${1:agree.png}", :id => "${2:id}"${0} %>
|
||||
snippet log
|
||||
Rails.logger.${1:debug} ${0}
|
||||
snippet log2
|
||||
RAILS_DEFAULT_LOGGER.${1:debug} ${0}
|
||||
snippet logd
|
||||
logger.debug { "${1:message}" }
|
||||
snippet loge
|
||||
logger.error { "${1:message}" }
|
||||
snippet logf
|
||||
logger.fatal { "${1:message}" }
|
||||
snippet logi
|
||||
logger.info { "${1:message}" }
|
||||
snippet logw
|
||||
logger.warn { "${1:message}" }
|
||||
snippet mapc
|
||||
${1:map}.${2:connect} '${0:controller/:action/:id}'
|
||||
snippet mapca
|
||||
${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}"
|
||||
snippet mapr
|
||||
${1:map}.resource :${0:resource}
|
||||
snippet maprs
|
||||
${1:map}.resources :${0:resource}
|
||||
snippet mapwo
|
||||
${1:map}.with_options :${2:controller} => '${3:thing}' do |$3|
|
||||
${0}
|
||||
end
|
||||
snippet mbs
|
||||
before_save :${0:method}
|
||||
snippet mcht
|
||||
change_table :${1:table_name} do |t|
|
||||
${0}
|
||||
end
|
||||
snippet mp
|
||||
map(&:${0:id})
|
||||
snippet mrw
|
||||
mattr_accessor :${0:attr_names}
|
||||
snippet oa
|
||||
order("${0:field}")
|
||||
snippet od
|
||||
order("${0:field} DESC")
|
||||
snippet pa
|
||||
params[:${1:id}]
|
||||
snippet ra
|
||||
render :action => "${0:action}"
|
||||
snippet ral
|
||||
render :action => "${1:action}", :layout => "${0:layoutname}"
|
||||
snippet rest
|
||||
respond_to do |format|
|
||||
format.${1:html} { ${0} }
|
||||
end
|
||||
snippet rf
|
||||
render :file => "${0:filepath}"
|
||||
snippet rfu
|
||||
render :file => "${1:filepath}", :use_full_path => ${0:false}
|
||||
snippet ri
|
||||
render :inline => "${0:<%= 'hello' %>}"
|
||||
snippet ril
|
||||
render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"${0} }
|
||||
snippet rit
|
||||
render :inline => "${1:<%= 'hello' %>}", :type => ${0::rxml}
|
||||
snippet rjson
|
||||
render :json => ${0:text to render}
|
||||
snippet rl
|
||||
render :layout => "${0:layoutname}"
|
||||
snippet rn
|
||||
render :nothing => ${0:true}
|
||||
snippet rns
|
||||
render :nothing => ${1:true}, :status => ${0:401}
|
||||
snippet rp
|
||||
render :partial => "${0:item}"
|
||||
snippet rpc
|
||||
render :partial => "${1:item}", :collection => ${0:@$1s}
|
||||
snippet rpl
|
||||
render :partial => "${1:item}", :locals => { :${2:$1} => ${0:@$1}
|
||||
snippet rpo
|
||||
render :partial => "${1:item}", :object => ${0:@$1}
|
||||
snippet rps
|
||||
render :partial => "${1:item}", :status => ${0:500}
|
||||
snippet rt
|
||||
render :text => "${0:text to render}"
|
||||
snippet rtl
|
||||
render :text => "${1:text to render}", :layout => "${0:layoutname}"
|
||||
snippet rtlt
|
||||
render :text => "${1:text to render}", :layout => ${0:true}
|
||||
snippet rts
|
||||
render :text => "${1:text to render}", :status => ${0:401}
|
||||
snippet ru
|
||||
render :update do |${1:page}|
|
||||
$1.${0}
|
||||
end
|
||||
snippet rxml
|
||||
render :xml => ${0:text to render}
|
||||
snippet sc
|
||||
scope :${1:name}, -> { where(${2:field}: ${0:value}) }
|
||||
snippet sl
|
||||
scope :${1:name}, lambda do |${2:value}|
|
||||
where("${3:field = ?}", ${0:bind var})
|
||||
end
|
||||
snippet sha1
|
||||
Digest::SHA1.hexdigest(${0:string})
|
||||
snippet sweeper
|
||||
class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper
|
||||
observe $1
|
||||
|
||||
def after_save(${0:model_class_name})
|
||||
expire_cache($2)
|
||||
end
|
||||
|
||||
def after_destroy($2)
|
||||
expire_cache($2)
|
||||
end
|
||||
|
||||
def expire_cache($2)
|
||||
expire_page
|
||||
end
|
||||
end
|
||||
snippet va validates_associated
|
||||
validates_associated :${0:attribute}
|
||||
snippet va validates .., :acceptance => true
|
||||
validates :${0:terms}, :acceptance => true
|
||||
snippet vc
|
||||
validates :${0:attribute}, :confirmation => true
|
||||
snippet ve
|
||||
validates :${1:attribute}, :exclusion => { :in => ${0:%w( mov avi )} }
|
||||
snippet vf
|
||||
validates :${1:attribute}, :format => { :with => /${0:regex}/ }
|
||||
snippet vi
|
||||
validates :${1:attribute}, :inclusion => { :in => %w(${0: mov avi }) }
|
||||
snippet vl
|
||||
validates :${1:attribute}, :length => { :in => ${2:3}..${0:20} }
|
||||
snippet vn
|
||||
validates :${0:attribute}, :numericality => true
|
||||
snippet vp
|
||||
validates :${0:attribute}, :presence => true
|
||||
snippet vu
|
||||
validates :${0:attribute}, :uniqueness => true
|
||||
snippet format
|
||||
format.${1:js|xml|html} { ${0} }
|
||||
snippet wc
|
||||
where(${1:"conditions"}${0:, bind_var})
|
||||
snippet wf
|
||||
where(${1:field} => ${0:value})
|
||||
snippet xdelete
|
||||
xhr :delete, :${1:destroy}, :id => ${2:1}
|
||||
snippet xget
|
||||
xhr :get, :${1:show}, :id => ${2:1}
|
||||
snippet xpost
|
||||
xhr :post, :${1:create}, :${2:object} => { ${0} }
|
||||
snippet xput
|
||||
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }
|
||||
snippet test
|
||||
test "should ${1:do something}" do
|
||||
${0}
|
||||
end
|
||||
###########################
|
||||
# migrations snippets #
|
||||
###########################
|
||||
snippet mac
|
||||
add_column :${1:table_name}, :${2:column_name}, :${0:data_type}
|
||||
snippet mai
|
||||
add_index :${1:table_name}, :${0:column_name}
|
||||
snippet mrc
|
||||
remove_column :${1:table_name}, :${0:column_name}
|
||||
snippet mrnc
|
||||
rename_column :${1:table_name}, :${2:old_column_name}, :${0:new_column_name}
|
||||
snippet mcc
|
||||
change_column :${1:table}, :${2:column}, :${0:type}
|
||||
snippet mnc
|
||||
t.${1:string} :${2:title}${3:, null: false}
|
||||
snippet mct
|
||||
create_table :${1:table_name} do |t|
|
||||
${0}
|
||||
end
|
||||
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
|
||||
class ${1:class_name} < ActiveRecord::Migration
|
||||
def up
|
||||
${0}
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
snippet migration class .. < ActiveRecord::Migration .. def change .. end
|
||||
class ${1:class_name} < ActiveRecord::Migration
|
||||
def change
|
||||
${0}
|
||||
end
|
||||
end
|
||||
snippet trc
|
||||
t.remove :${0:column}
|
||||
snippet tre
|
||||
t.rename :${1:old_column_name}, :${2:new_column_name}
|
||||
${0}
|
||||
snippet tref
|
||||
t.references :${0:model}
|
||||
snippet tcb
|
||||
t.boolean :${1:title}
|
||||
${0}
|
||||
snippet tcbi
|
||||
t.binary :${1:title}, :limit => ${2:2}.megabytes
|
||||
${0}
|
||||
snippet tcd
|
||||
t.decimal :${1:title}, :precision => ${2:10}, :scale => ${3:2}
|
||||
${0}
|
||||
snippet tcda
|
||||
t.date :${1:title}
|
||||
${0}
|
||||
snippet tcdt
|
||||
t.datetime :${1:title}
|
||||
${0}
|
||||
snippet tcf
|
||||
t.float :${1:title}
|
||||
${0}
|
||||
snippet tch
|
||||
t.change :${1:name}, :${2:string}, :${3:limit} => ${4:80}
|
||||
${0}
|
||||
snippet tci
|
||||
t.integer :${1:title}
|
||||
${0}
|
||||
snippet tcl
|
||||
t.integer :lock_version, :null => false, :default => 0
|
||||
${0}
|
||||
snippet tcr
|
||||
t.references :${1:taggable}, :polymorphic => { :default => '${2:Photo}' }
|
||||
${0}
|
||||
snippet tcs
|
||||
t.string :${1:title}
|
||||
${0}
|
||||
snippet tct
|
||||
t.text :${1:title}
|
||||
${0}
|
||||
snippet tcti
|
||||
t.time :${1:title}
|
||||
${0}
|
||||
snippet tcts
|
||||
t.timestamp :${1:title}
|
||||
${0}
|
||||
snippet tctss
|
||||
t.timestamps
|
||||
${0}
|
||||
strftime('${1:%Y-%m-%d %H:%M:%S %z}')${0}
|
||||
#
|
||||
# Minitest snippets
|
||||
#
|
||||
snippet mb
|
||||
must_be ${0}
|
||||
snippet wb
|
||||
wont_be ${0}
|
||||
snippet mbe
|
||||
must_be_empty
|
||||
snippet wbe
|
||||
wont_be_empty
|
||||
snippet mbio
|
||||
must_be_instance_of ${0:Class}
|
||||
snippet wbio
|
||||
wont_be_instance_of ${0:Class}
|
||||
snippet mbko
|
||||
must_be_kind_of ${0:Class}
|
||||
snippet wbko
|
||||
wont_be_kind_of ${0:Class}
|
||||
snippet mbn
|
||||
must_be_nil
|
||||
snippet wbn
|
||||
wont_be_nil
|
||||
snippet mbsa
|
||||
must_be_same_as ${0:other}
|
||||
snippet wbsa
|
||||
wont_be_same_as ${0:other}
|
||||
snippet mbsi
|
||||
-> { ${0} }.must_be_silent
|
||||
snippet mbwd
|
||||
must_be_within_delta ${1:0.1}, ${2:0.1}
|
||||
snippet wbwd
|
||||
wont_be_within_delta ${1:0.1}, ${2:0.1}
|
||||
snippet mbwe
|
||||
must_be_within_epsilon ${1:0.1}, ${2:0.1}
|
||||
snippet wbwe
|
||||
wont_be_within_epsilon ${1:0.1}, ${2:0.1}
|
||||
snippet me
|
||||
must_equal ${0:other}
|
||||
snippet we
|
||||
wont_equal ${0:other}
|
||||
snippet mi
|
||||
must_include ${0:what}
|
||||
snippet wi
|
||||
wont_include ${0:what}
|
||||
snippet mm
|
||||
must_match /${0:regex}/
|
||||
snippet wm
|
||||
wont_match /${0:regex}/
|
||||
snippet mout
|
||||
-> { ${1} }.must_output '${0}'
|
||||
snippet mra
|
||||
-> { ${1} }.must_raise ${0:Exception}
|
||||
snippet mrt
|
||||
must_respond_to :${0:method}
|
||||
snippet wrt
|
||||
wont_respond_to :${0:method}
|
||||
snippet msend
|
||||
must_send [ ${1:what}, :${2:method}, ${3:args} ]
|
||||
snippet mthrow
|
||||
-> { throw :${1:error} }.must_throw :${2:error}
|
||||
##########################
|
||||
# Rspec snippets #
|
||||
##########################
|
||||
@ -971,11 +668,11 @@ snippet desc
|
||||
${0}
|
||||
end
|
||||
snippet descm
|
||||
describe "${1:#method}" do
|
||||
${0:pending "Not implemented"}
|
||||
describe '${1:#method}' do
|
||||
${0:pending 'Not implemented'}
|
||||
end
|
||||
snippet cont
|
||||
context "${1:message}" do
|
||||
context '${1:message}' do
|
||||
${0}
|
||||
end
|
||||
snippet bef
|
||||
@ -987,9 +684,9 @@ snippet aft
|
||||
${0}
|
||||
end
|
||||
snippet let
|
||||
let(:${1:object}) ${0}
|
||||
let(:${1:object}) { ${0} }
|
||||
snippet let!
|
||||
let!(:${1:object}) ${0}
|
||||
let!(:${1:object}) { ${0} }
|
||||
snippet subj
|
||||
subject { ${0} }
|
||||
snippet s.
|
||||
@ -1003,11 +700,11 @@ snippet expb
|
||||
snippet experr
|
||||
expect { ${1:object} }.to raise_error ${2:StandardError}, /${0:message_regex}/
|
||||
snippet shared
|
||||
shared_examples ${0:"shared examples name"}
|
||||
shared_examples ${0:'shared examples name'}
|
||||
snippet ibl
|
||||
it_behaves_like ${0:"shared examples name"}
|
||||
it_behaves_like ${0:'shared examples name'}
|
||||
snippet it
|
||||
it "${1:spec_name}" do
|
||||
it '${1:spec_name}' do
|
||||
${0}
|
||||
end
|
||||
snippet its
|
||||
@ -1016,74 +713,3 @@ snippet is
|
||||
it { should ${0} }
|
||||
snippet isn
|
||||
it { should_not ${0} }
|
||||
#ShouldaMatchers#ActionController
|
||||
snippet isfp
|
||||
it { should filter_param :${0:key} }
|
||||
snippet isrt
|
||||
it { should redirect_to ${0:url} }
|
||||
snippet isrtp
|
||||
it { should render_template ${0} }
|
||||
snippet isrwl
|
||||
it { should render_with_layout ${0} }
|
||||
snippet isrf
|
||||
it { should rescue_from ${0:exception} }
|
||||
snippet isrw
|
||||
it { should respond_with ${0:status} }
|
||||
snippet isr
|
||||
it { should route(:${1:method}, '${0:path}') }
|
||||
snippet isss
|
||||
it { should set_session :${0:key} }
|
||||
snippet issf
|
||||
it { should set_the_flash('${0}') }
|
||||
#ShouldaMatchers#ActiveModel
|
||||
snippet isama
|
||||
it { should allow_mass_assignment_of :${0} }
|
||||
snippet isav
|
||||
it { should allow_value(${1}).for :${0} }
|
||||
snippet isee
|
||||
it { should ensure_exclusion_of :${0} }
|
||||
snippet isei
|
||||
it { should ensure_inclusion_of :${0} }
|
||||
snippet isel
|
||||
it { should ensure_length_of :${0} }
|
||||
snippet isva
|
||||
it { should validate_acceptance_of :${0} }
|
||||
snippet isvc
|
||||
it { should validate_confirmation_of :${0} }
|
||||
snippet isvn
|
||||
it { should validate_numericality_of :${0} }
|
||||
snippet isvp
|
||||
it { should validate_presence_of :${0} }
|
||||
snippet isvu
|
||||
it { should validate_uniqueness_of :${0} }
|
||||
#ShouldaMatchers#ActiveRecord
|
||||
snippet isana
|
||||
it { should accept_nested_attributes_for :${0} }
|
||||
snippet isbt
|
||||
it { should belong_to :${0} }
|
||||
snippet isbtcc
|
||||
it { should belong_to(:${1}).counter_cache ${0:true} }
|
||||
snippet ishbtm
|
||||
it { should have_and_belong_to_many :${0} }
|
||||
snippet isbv
|
||||
it { should be_valid }
|
||||
snippet ishc
|
||||
it { should have_db_column :${0} }
|
||||
snippet ishi
|
||||
it { should have_db_index :${0} }
|
||||
snippet ishm
|
||||
it { should have_many :${0} }
|
||||
snippet ishmt
|
||||
it { should have_many(:${1}).through :${0} }
|
||||
snippet isho
|
||||
it { should have_one :${0} }
|
||||
snippet ishro
|
||||
it { should have_readonly_attribute :${0} }
|
||||
snippet iss
|
||||
it { should serialize :${0} }
|
||||
snippet isres
|
||||
it { should respond_to :${0} }
|
||||
snippet isresw
|
||||
it { should respond_to(:${1}).with(${0}).arguments }
|
||||
snippet super_call
|
||||
${1:super_class}.instance_method(:${0:method}).bind(self).call
|
||||
|
@ -194,8 +194,9 @@ snippet mhmap
|
||||
snippet as
|
||||
${1:name}.asInstanceOf[${2:T}]
|
||||
#isInstanceOf[]
|
||||
snippet is
|
||||
${1:name}.isInstanceOf[${2:T}]
|
||||
#end
|
||||
|
||||
#collections methods
|
||||
|
||||
#scope() with one arg
|
||||
|
@ -81,7 +81,7 @@ snippet getopt
|
||||
done
|
||||
shift $(($OPTIND-1))
|
||||
snippet root
|
||||
if [ $(id -u) -ne 0 ]; then exec sudo $0; fi
|
||||
if [ \$(id -u) -ne 0 ]; then exec sudo \$0; fi
|
||||
snippet fun
|
||||
${1:function_name}() {
|
||||
${0:#function_body}
|
||||
|
@ -1,215 +1,224 @@
|
||||
#PREAMBLE
|
||||
#newcommand
|
||||
snippet nc
|
||||
\newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0}
|
||||
snippet nc \newcommand
|
||||
\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0}
|
||||
#usepackage
|
||||
snippet up
|
||||
snippet up \usepackage
|
||||
\usepackage[${1:options}]{${2:package}} ${0}
|
||||
#newunicodechar
|
||||
snippet nuc
|
||||
snippet nuc \newunicodechar
|
||||
\newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${0}
|
||||
#DeclareMathOperator
|
||||
snippet dmo
|
||||
snippet dmo \DeclareMathOperator
|
||||
\DeclareMathOperator{${1}}{${2}} ${0}
|
||||
|
||||
#DOCUMENT
|
||||
# \begin{}...\end{}
|
||||
snippet begin
|
||||
snippet begin \begin{} ... \end{} block
|
||||
\begin{${1:env}}
|
||||
${0}
|
||||
\end{$1}
|
||||
# Tabular
|
||||
snippet tab
|
||||
snippet tab tabular (or arbitrary) environment
|
||||
\begin{${1:tabular}}{${2:c}}
|
||||
${0}
|
||||
${0}
|
||||
\end{$1}
|
||||
snippet thm
|
||||
snippet thm thm (or arbitrary) environment with optional argument
|
||||
\begin[${1:author}]{${2:thm}}
|
||||
${0}
|
||||
${0}
|
||||
\end{$2}
|
||||
snippet center
|
||||
snippet center center environment
|
||||
\begin{center}
|
||||
${0}
|
||||
\end{center}
|
||||
# Align(ed)
|
||||
snippet ali
|
||||
snippet ali align(ed) environment
|
||||
\begin{align${1:ed}}
|
||||
\label{eq:${2}}
|
||||
${0}
|
||||
\end{align$1}
|
||||
# Gather(ed)
|
||||
snippet gat
|
||||
snippet gat gather(ed) environment
|
||||
\begin{gather${1:ed}}
|
||||
${0}
|
||||
\end{gather$1}
|
||||
# Equation
|
||||
snippet eq
|
||||
snippet eq equation environment
|
||||
\begin{equation}
|
||||
\label{eq:${2}}
|
||||
${0}
|
||||
\end{equation}
|
||||
# Equation
|
||||
snippet eq*
|
||||
snippet eq* unnumbered equation environment
|
||||
\begin{equation*}
|
||||
${0}
|
||||
\end{equation*}
|
||||
# Unnumbered Equation
|
||||
snippet \
|
||||
snippet \ unnumbered equation: \[ ... \]
|
||||
\[
|
||||
${0}
|
||||
\]
|
||||
# Equation array
|
||||
snippet eqnarray
|
||||
snippet eqnarray eqnarray environment
|
||||
\begin{eqnarray}
|
||||
${0}
|
||||
\end{eqnarray}
|
||||
# Label
|
||||
snippet lab \label
|
||||
\label{${1:eq:}${2:fig:}${3:tab:}${0}}
|
||||
# Enumerate
|
||||
snippet enum
|
||||
snippet enum enumerate environment
|
||||
\begin{enumerate}
|
||||
\item ${0}
|
||||
\end{enumerate}
|
||||
# Itemize
|
||||
snippet itemize
|
||||
snippet itemize itemize environment
|
||||
\begin{itemize}
|
||||
\item ${0}
|
||||
\end{itemize}
|
||||
snippet item
|
||||
snippet item \item
|
||||
\item ${1}
|
||||
# Description
|
||||
snippet desc
|
||||
snippet desc description environment
|
||||
\begin{description}
|
||||
\item[${1}] ${0}
|
||||
\end{description}
|
||||
# Endless new item
|
||||
snippet ]i
|
||||
snippet ]i \item (recursive)
|
||||
\item ${1}
|
||||
${0:]i}
|
||||
${0:]i}
|
||||
# Matrix
|
||||
snippet mat
|
||||
snippet mat smart matrix environment
|
||||
\begin{${1:p/b/v/V/B/small}matrix}
|
||||
${0}
|
||||
\end{$1matrix}
|
||||
# Cases
|
||||
snippet cas
|
||||
snippet cas cases environment
|
||||
\begin{cases}
|
||||
${1:equation}, &\text{ if }${2:case}\\
|
||||
${0}
|
||||
\end{cases}
|
||||
# Split
|
||||
snippet spl
|
||||
snippet spl split environment
|
||||
\begin{split}
|
||||
${0}
|
||||
\end{split}
|
||||
# Part
|
||||
snippet part
|
||||
snippet part document \part
|
||||
\part{${1:part name}} % (fold)
|
||||
\label{prt:${2:$1}}
|
||||
${0}
|
||||
% part $2 (end)
|
||||
# Chapter
|
||||
snippet cha
|
||||
snippet cha \chapter
|
||||
\chapter{${1:chapter name}}
|
||||
\label{cha:${2:$1}}
|
||||
${0}
|
||||
# Section
|
||||
snippet sec
|
||||
snippet sec \section
|
||||
\section{${1:section name}}
|
||||
\label{sec:${2:$1}}
|
||||
${0}
|
||||
# Section without number
|
||||
snippet sec*
|
||||
snippet sec* \section*
|
||||
\section*{${1:section name}}
|
||||
\label{sec:${2:$1}}
|
||||
${0}
|
||||
# Sub Section
|
||||
snippet sub
|
||||
snippet sub \subsection
|
||||
\subsection{${1:subsection name}}
|
||||
\label{sub:${2:$1}}
|
||||
${0}
|
||||
# Sub Section without number
|
||||
snippet sub*
|
||||
snippet sub* \subsection*
|
||||
\subsection*{${1:subsection name}}
|
||||
\label{sub:${2:$1}}
|
||||
${0}
|
||||
# Sub Sub Section
|
||||
snippet subs
|
||||
snippet subs \subsubsection
|
||||
\subsubsection{${1:subsubsection name}}
|
||||
\label{ssub:${2:$1}}
|
||||
${0}
|
||||
# Sub Sub Section without number
|
||||
snippet subs*
|
||||
snippet subs* \subsubsection*
|
||||
\subsubsection*{${1:subsubsection name}}
|
||||
\label{ssub:${2:$1}}
|
||||
${0}
|
||||
# Paragraph
|
||||
snippet par
|
||||
snippet par \paragraph
|
||||
\paragraph{${1:paragraph name}}
|
||||
\label{par:${2:$1}}
|
||||
${0}
|
||||
# Sub Paragraph
|
||||
snippet subp
|
||||
snippet subp \subparagraph
|
||||
\subparagraph{${1:subparagraph name}}
|
||||
\label{subp:${2:$1}}
|
||||
${0}
|
||||
snippet ni
|
||||
snippet ni \noindent
|
||||
\noindent
|
||||
${0}
|
||||
#References
|
||||
snippet itd
|
||||
snippet itd description \item
|
||||
\item[${1:description}] ${0:item}
|
||||
snippet figure
|
||||
snippet figure reference to a figure
|
||||
${1:Figure}~\ref{${2:fig:}}
|
||||
snippet table
|
||||
snippet table reference to a table
|
||||
${1:Table}~\ref{${2:tab:}}
|
||||
snippet listing
|
||||
snippet listing reference to a listing
|
||||
${1:Listing}~\ref{${2:list}}
|
||||
snippet section
|
||||
snippet section reference to a section
|
||||
${1:Section}~\ref{sec:${2}} ${0}
|
||||
snippet page
|
||||
snippet page reference to a page
|
||||
${1:page}~\pageref{${2}} ${0}
|
||||
snippet index
|
||||
snippet index \index
|
||||
\index{${1:index}} ${0}
|
||||
#Citations
|
||||
snippet citen
|
||||
\cite{$1} ${0}
|
||||
# bibtex commands
|
||||
snippet citep
|
||||
\citep{$1} ${0}
|
||||
snippet citet
|
||||
\citet{$1} ${0}
|
||||
snippet cite
|
||||
snippet citen \citen
|
||||
\citen{${1}} ${0}
|
||||
# natbib citations
|
||||
snippet citep \citep
|
||||
\citep{${1}} ${0}
|
||||
snippet citet \citet
|
||||
\citet{${1}} ${0}
|
||||
snippet cite \cite[]{}
|
||||
\cite[${1}]{${2}} ${0}
|
||||
snippet fcite
|
||||
snippet citea \citeauthor
|
||||
\citeauthor{${1}} ${0}
|
||||
snippet citey \citeyear
|
||||
\citeyear{${1}} ${0}
|
||||
snippet fcite \footcite[]{}
|
||||
\footcite[${1}]{${2}}${0}
|
||||
#Formating text: italic, bold, underline, small capital, emphase ..
|
||||
snippet it
|
||||
snippet it italic text
|
||||
\textit{${0:text}}
|
||||
snippet bf
|
||||
snippet bf bold face text
|
||||
\textbf{${0:text}}
|
||||
snippet under
|
||||
snippet under underline text
|
||||
\underline{${0:text}}
|
||||
snippet emp
|
||||
snippet emp emphasize text
|
||||
\emph{${0:text}}
|
||||
snippet sc
|
||||
snippet sc small caps text
|
||||
\textsc{${0:text}}
|
||||
#Choosing font
|
||||
snippet sf
|
||||
snippet sf sans serife text
|
||||
\textsf{${0:text}}
|
||||
snippet rm
|
||||
snippet rm roman font text
|
||||
\textrm{${0:text}}
|
||||
snippet tt
|
||||
snippet tt typewriter (monospace) text
|
||||
\texttt{${0:text}}
|
||||
#misc
|
||||
snippet ft
|
||||
snippet ft \footnote
|
||||
\footnote{${0:text}}
|
||||
snippet fig
|
||||
snippet fig figure environment (includegraphics)
|
||||
\begin{figure}
|
||||
\begin{center}
|
||||
\includegraphics[scale=${1}]{Figures/${2}}
|
||||
\includegraphics[scale=${1}]{Figures/${2}}
|
||||
\end{center}
|
||||
\caption{${3}}
|
||||
\label{fig:${4}}
|
||||
\end{figure}
|
||||
${0}
|
||||
snippet tikz
|
||||
snippet tikz figure environment (tikzpicture)
|
||||
\begin{figure}
|
||||
\begin{center}
|
||||
\begin{tikzpicture}[scale=${1:1}]
|
||||
@ -221,33 +230,31 @@ snippet tikz
|
||||
\end{figure}
|
||||
${0}
|
||||
#math
|
||||
snippet stackrel
|
||||
snippet stackrel \stackrel{}{}
|
||||
\stackrel{${1:above}}{${2:below}} ${0}
|
||||
snippet frac
|
||||
snippet frac \frac{}{}
|
||||
\frac{${1:num}}{${2:denom}} ${0}
|
||||
snippet sum
|
||||
snippet sum \sum^{}_{}
|
||||
\sum^{${1:n}}_{${2:i=1}} ${0}
|
||||
snippet lim
|
||||
snippet lim \lim_{}
|
||||
\lim_{${1:x \to +\infty}} ${0}
|
||||
snippet frame
|
||||
\begin{frame}[<+->]
|
||||
\frametitle{${1:title}}
|
||||
|
||||
snippet frame frame environment
|
||||
\begin{frame}[${1:t}]{${2:title}}
|
||||
${0}
|
||||
\end{frame}
|
||||
snippet block
|
||||
snippet block block environment
|
||||
\begin{block}{${1:title}}
|
||||
${0}
|
||||
\end{block}
|
||||
snippet alert
|
||||
snippet alert alertblock environment
|
||||
\begin{alertblock}{${1:title}}
|
||||
${0}
|
||||
\end{alertblock}
|
||||
snippet example
|
||||
snippet example exampleblock environment
|
||||
\begin{exampleblock}{${1:title}}
|
||||
${0}
|
||||
\end{exampleblock}
|
||||
snippet col2
|
||||
snippet col2 two-column environment
|
||||
\begin{columns}
|
||||
\begin{column}{0.5\textwidth}
|
||||
${1}
|
||||
@ -256,3 +263,20 @@ snippet col2
|
||||
${0}
|
||||
\end{column}
|
||||
\end{columns}
|
||||
# Code listings
|
||||
snippet lst
|
||||
\begin{listing}[language=${1:language}]
|
||||
${0}
|
||||
\end{listing}
|
||||
snippet lsi
|
||||
\lstinline|${1}| ${0}
|
||||
# Hyperlinks
|
||||
snippet url
|
||||
\url{${1}} ${0}
|
||||
snippet href
|
||||
\href{${1}}{${2}} ${0}
|
||||
# URL from Clipboard.
|
||||
snippet urlc
|
||||
\url{`@+`} ${0}
|
||||
snippet hrefc
|
||||
\href{`@+`}{${1}} ${0}
|
||||
|
@ -1,50 +1,52 @@
|
||||
snippet header
|
||||
snippet header standard Vim script file header
|
||||
" File: ${1:`expand('%:t')`}
|
||||
" Author: ${2:`g:snips_author`}
|
||||
" Description: ${3}
|
||||
${0:" Last Modified: `strftime("%B %d, %Y")`}
|
||||
snippet guard
|
||||
snippet guard script reload guard
|
||||
if exists('${1:did_`vim_snippets#Filename()`}') || &cp${2: || version < 700}
|
||||
finish
|
||||
endif
|
||||
let $1 = 1${0}
|
||||
snippet f
|
||||
snippet f function
|
||||
fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3})
|
||||
${0}
|
||||
endf
|
||||
snippet t
|
||||
snippet t try ... catch statement
|
||||
try
|
||||
${1}
|
||||
catch ${2}
|
||||
${0}
|
||||
endtry
|
||||
snippet for
|
||||
snippet for for ... in loop
|
||||
for ${1} in ${2}
|
||||
${0}
|
||||
endfor
|
||||
snippet forkv
|
||||
snippet forkv for [key, value] in loop
|
||||
for [${1},${2}] in items(${3})
|
||||
${0}
|
||||
unlet $1 $2
|
||||
endfor
|
||||
snippet wh
|
||||
snippet wh while loop
|
||||
while ${1}
|
||||
${0}
|
||||
endw
|
||||
snippet if
|
||||
snippet if if statement
|
||||
if ${1}
|
||||
${0}
|
||||
endif
|
||||
snippet ife
|
||||
snippet ife if ... else statement
|
||||
if ${1}
|
||||
${2}
|
||||
else
|
||||
${0}
|
||||
endif
|
||||
snippet au
|
||||
snippet au augroup ... autocmd block
|
||||
augroup ${1:AU_NAME}
|
||||
" this one is which you're most likely to use?
|
||||
autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|<buffer[=N]>} ${0}
|
||||
augroup end
|
||||
snippet bun
|
||||
Bundle '${0}'
|
||||
snippet bun Vundle.vim Plugin definition
|
||||
Plugin '${0}'
|
||||
snippet plug Vundle.vim Plugin definition
|
||||
Plugin '${0}'
|
||||
|
@ -13,14 +13,14 @@ snippet ife
|
||||
${0:# statements}
|
||||
fi
|
||||
snippet eif
|
||||
elif ${1:condition} ; then
|
||||
elif ${1:condition}; then
|
||||
${0:# statements}
|
||||
snippet for
|
||||
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||
${0:# statements}
|
||||
done
|
||||
snippet fori
|
||||
for ${1:needle} in ${2:haystack} ; do
|
||||
for ${1:needle} in ${2:haystack}; do
|
||||
${0:#statements}
|
||||
done
|
||||
snippet fore
|
||||
@ -57,6 +57,10 @@ snippet [
|
||||
snippet always
|
||||
{ ${1:try} } always { ${0:always} }
|
||||
snippet fun
|
||||
function ${1:name} (${2:args}) {
|
||||
${0:# body}
|
||||
${1:function_name}() {
|
||||
${0:# function_body}
|
||||
}
|
||||
snippet ffun
|
||||
function ${1:function_name}() {
|
||||
${0:# function_body}
|
||||
}
|
||||
|
Reference in New Issue
Block a user