Wiki

Clone wiki

VimLabo / neosnippet-sublime_snippets

とりあえずためしに前作ったtableに格納したsnippet情報からviewとしてneosnippetとsublime textのsnippet作るやつが以外にうまく使えててびっくり。 本気でこういう運用にしようか思い始めてきた。

元テーブル

CREATE TABLE SNIPPET
(
    NAME                           VARCHAR2(255)
    , CONTENT                        VARCHAR2(4000)
    , ABBR                           VARCHAR2(255)
    , DESCRIPTION                    VARCHAR2(255)
    , TABTRIGGER                     VARCHAR2(100)
    , SCOPE                          VARCHAR2(100)
    , OPTIONS                        VARCHAR2(100)
)

SUBLIME TEXT用

CREATE OR REPLACE VIEW SUBLIME_SNIPPET
    (SNIPPET_NAME, BODY, SCOPE)
AS
SELECT 
        NAME AS SNIPPET_NAME
        ,               '<SNIPPET>'
        || CHR(10) ||       '<CONTENT>'
        || CHR(10) ||           CONTENT
        || CHR(10) ||       '</CONTENT>'
        || CHR(10) ||       '<TABTRIGGER>'  || TABTRIGGER   || '</TABTRIGGER>' 
        || CHR(11) ||       '<SCOPE>'       || SCOPE        || '</SCOPE>'
        || CHR(10) ||       '<DESCRIPTION>' || DESCRIPTION  || '</DESCRIPTION>' 
        || CHR(10) ||   '</SNIPPET>' AS BODY
        , SCOPE
    FROM
        SNIPPET

NEOSNIPPET用

CREATE OR REPLACE VIEW NEOSNIPPET_SNIPPET
    (SNIPPET_NAME, BODY, SCOPE)
AS
select 
        NAME AS SNIPPET_NAME
        ,               'snippet        ' || NAME
        || CHR(10) ||   'abbr           ' || ABBR
        || CHR(10) ||   'options        ' || OPTIONS 
        || CHR(10) ||    CHR(9) 
        || replace(CONTENT, CHR(10), CHR(10) || CHR(9)) AS BODY
        , SCOPE
    FROM 
        snippet

Updated