Skip to content

Commit

Permalink
Introduce triple bang syntax to remove triggers
Browse files Browse the repository at this point in the history
In a snippets file, `snippet!!! foo` will remove the trigger from the
current lookup for the current context. Load order still matters.

This is useful to override a series of triggers with different
descriptions, and turn that into a single trigger, so that you don't
have to choose.
  • Loading branch information
somini committed Mar 6, 2016
1 parent 71250b0 commit 0d3fbec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions autoload/snipMate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ fun! snipMate#ReadSnippetsFile(file) abort
if line[:6] == 'snippet'
let inSnip = 1
let bang = (line[7] == '!')
if bang
if bang "!!
let bang += line[8] == '!'
endif
if bang "!!!
let bang += line[9] == '!'
endif
let trigger = strpart(line, 8 + bang)
let name = ''
let space = stridx(trigger, ' ') + 1
Expand Down Expand Up @@ -341,7 +344,13 @@ endfunction

function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort
let d = a:dict
if a:bang == 2
if a:bang == 3
unlet! d[a:trigger][a:path]
if len(d[a:trigger]) == 0
unlet! d[a:trigger]
endif
return
elseif a:bang == 2
unlet! d[a:trigger]
return
elseif !has_key(d, a:trigger) || a:bang == 1
Expand Down
3 changes: 3 additions & 0 deletions doc/SnipMate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ overridden on a per-snippet basis by defining the snippet with a bang (!): >
Two bangs will remove the trigger entirely from SnipMate's lookup. In this
case any snippet text is unused.

Three bangs will remove the trigger from the current scope. In this
case any snippet text is unused.

Note: Hard tabs in the expansion text are required. When the snippet is
expanded in the text and 'expandtab' is set, each tab will be replaced with
spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise.
Expand Down

0 comments on commit 0d3fbec

Please sign in to comment.